Silverlight安全异常
我将数据 POST 到服务器并成功执行 BeginGetRequestStream,然后执行 EndGetRequestStream,将 POST 数据写入填充 RequestStream,然后调用 BeginGetResponse。
BeginGetResponse 成功返回,然后我调用:
Dim response As HttpWebResponse = CType(MyHttpRequest.EndGetResponse(asynchronousResult), HttpWebResponse)
此行抛出以下 SecurityException 错误:
{System.Security.SecurityException ---> System.Security.SecurityException:安全错误。
在 System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
在 System.Net.Browser.BrowserHttpWebRequest。<>c__DisplayClass5.b__4(Object sendState)
在 System.Net.Browser.AsyncHelper.<>c__DisplayClass2.b__0(Object sendState)--- 内部异常堆栈跟踪结束 ---
在 System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,对象状态)
在 System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
在 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 会抛出这个错误?
谢谢
I'm POSTing data to a server and successfully execute BeginGetRequestStream, then EndGetRequestStream, write my POST data to the fill the RequestStream, and call BeginGetResponse.
BeginGetResponse successfully returns and I then call:
Dim response As HttpWebResponse = CType(MyHttpRequest.EndGetResponse(asynchronousResult), HttpWebResponse)
This line throws the folloing SecurityException Error:
{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)}
So my first thought was that I was being blocked by the server with their clientaccesspolicy.xml or crossdomain.xml. I've fired up Fiddler and saw the following:
GET http://openapi.etsy.com/clientaccesspolicy.xml > 596 (text/xml)
GET http://openapi.etsy.com/crossdomain.xml > 200 OK (application/xml)
So I checked their crossdomain.xml and the settings appear ok:
<!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>
I've hit a dead end in trying to solve this problem. I'm running the test app on my dev machine from VS.
Does anyone have any ideas as to why Silverlight would be throwing this error?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这似乎是客户端访问策略问题,请检查:
http://forums。 silverlight.net/forums/p/26566/90867.aspx
它对我有用。
It seems like it's a client access policy issue, check this:
http://forums.silverlight.net/forums/p/26566/90867.aspx
It worked for me.
我今天处理了一个非常相似的问题 - 但是我尝试执行 WCF 服务调用,而不是 HTTP POST。
这是我在代码中添加的注释 - 如果它不够清晰而没有帮助,请告诉我。
这似乎是一些安全“功能”。通过 WCF 调用,甚至在 Silverlight 客户端尝试从目标主机获取 clientaccesspolicy.xml 之前,我就遇到了此异常。非常烦人的问题,看不到真正的解决方案!
I dealt with a very similar problem today - however instead of an HTTP POST, I was attempting to do a WCF service call.
Here is the comment I placed in my code - please let me know if its not clear enough to be helpful.
This seems to be some security 'feature'. With the WCF call I got this exception even before the Silverlight client attempted to fetch the clientaccesspolicy.xml from the target host. Very annoying issue without a real solution in sight!