我正在尝试将带有GET请求的JSON列表加载到我的localhost(WAMP)上的PHP文件到我的Silverlight + Webproj解决方案中:
HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
request.BeginGetRequestStream(GetRequestStreamCallback, request);
private void GetRequestStreamCallback(IAsyncResult asynchronousResult)
{
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
Stream postStream = request.EndGetRequestStream(asynchronousResult);
byte[] byteArray = Encoding.UTF8.GetBytes(postInformation);
postStream.Write(byteArray, 0, postInformation.Length);
postStream.Close();
request.BeginGetResponse(DownloadCompleted, request);
}
private void DownloadCompleted(IAsyncResult asynchronousResult)
{
... load the data from the response , etc
}
这对于另一个网站来说完全相同。但现在我得到了这个安全例外:
{System.Security.SecurityException ---> System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa. <EndGetResponse>b__9(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>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 KunstWebsite.Model.Factory`1.DownloadCompleted(IAsyncResult asynchronousResult)}
我尝试了一些解决方案,我发现像添加clientaccesspolicy.xml,crossdomain.xml,将localhost作为可信站点,将trust level =“Full”添加到我的web.config中。 它们似乎都不起作用......
任何人都知道我可能忽略了什么?