我正在向服务器POST数据,并成功执行了BeginGetRequestStream,然后是EndGetRequestStream,将我的POST数据写入请求流(RequestStream),并调用BeginGetResponse。
BeginGetResponse成功返回,然后我调用:
这行代码会抛出以下SecurityException错误:
{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 EtsyV2NetSL.WebQuery.POST_ResponseCallback(IAsyncResult asynchronousResult)}
因此,我首先想到的是服务器通过其clientaccesspolicy.xml或crossdomain.xml阻止了我的请求。我启动了Fiddler并看到以下内容:
BeginGetResponse成功返回,然后我调用:
Dim response As HttpWebResponse = CType(MyHttpRequest.EndGetResponse(asynchronousResult), HttpWebResponse)
这行代码会抛出以下SecurityException错误:
{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 EtsyV2NetSL.WebQuery.POST_ResponseCallback(IAsyncResult asynchronousResult)}
因此,我首先想到的是服务器通过其clientaccesspolicy.xml或crossdomain.xml阻止了我的请求。我启动了Fiddler并看到以下内容:
GET http://openapi.etsy.com/clientaccesspolicy.xml > 596 (text/xml)
GET http://openapi.etsy.com/crossdomain.xml > 200 OK (application/xml)
所以我检查了他们的crossdomain.xml文件,设置看起来没问题:
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
我在尝试解决这个问题时遇到了瓶颈。我正在使用VS从我的开发机器上运行测试应用程序。
是否有人知道为什么Silverlight会抛出这个错误?
谢谢!