Not really sure why I’m getting the exception.. the code is sound and the API is working through my browser.
var url = new Uri("http://octopart.com/api/search?keywords=" + topic.Text);
WebClient octopartCall = new WebClient();
octopartCall.OpenReadCompleted += new OpenReadCompletedEventHandler(Octopart_Completed);
octopartCall.OpenReadAsync(url);
if (e.Error == null)
... error is not null so I throw the message below
System.Exception occurred
Message=System.Security.SecurityException —> System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.b__0(Object sendState)
— End of inner exception stack trace —
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
at System.Net.WebClient.OpenReadAsyncCallback(IAsyncResult result)
StackTrace:
at Register.Page.Octopart_Completed(Object sender, OpenReadCompletedEventArgs e)
InnerException:
The Visual Studio built in web server can’t handle cross domain connections.
Solution 1: make a new virtual directory for your project and run in IIS
Solution 2: add crossdomain.xml configuration file to your website project containing