gpt4 book ai didi

silverlight-4.0 - Silverlight 安全异常

转载 作者:行者123 更新时间:2023-12-04 10:57:59 25 4
gpt4 key购买 nike

我将数据 POST 到服务器并成功执行 BeginGetRequestStream,然后执行 EndGetRequestStream,将我的 POST 数据写入 RequestStream,并调用 BeginGetResponse。

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 会抛出这个错误?

谢谢

最佳答案

我今天处理了一个非常相似的问题 - 但是我尝试执行 WCF 服务调用而不是 HTTP POST。

这是我在代码中放置的注释 - 如果它不够清楚而无法提供帮助,请告诉我。

// NB: Cross-domain bug
// If you end up here with a System.Security.SecurityException "Security error."
// Check that you're not trying to cross zones when making a service call
// (eg: Accessing Trigger Driver TimeSource service on http://IASWEB01/ when accessing the site via usertest.local
// or any other URI with dots in it - yes it seems crazy)

这似乎是一些安全“功能”。通过 WCF 调用,我什至在 Silverlight 客户端尝试从目标主机获取 clientaccesspolicy.xml 之前就收到了此异常。非常烦人的问题,没有真正的解决方案!

关于silverlight-4.0 - Silverlight 安全异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4209050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com