异常代码发生在第二句
httpWebRequest request = result.AsyncState as httpWebRequest;
WebResponse response = request.EndGetResponse(result);
提示信息:
System.Security.SecurityException ---> System.Security.SecurityException: 安全性错误。
位于 System.Net.browser.browserhttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)位于 System.Net.browser.browserhttpWebRequest.<>c__displayClass5.<EndGetResponse>b__4(Object sendState)
位于 System.Net.browser.AsyncHelper.<>c__displayClass2.<BeginonUI>b__0(Object sendState)
--- 内部异常堆栈跟踪的结尾 ---
位于 System.Net.browser.AsyncHelper.BeginonUI(SendOrPostCallback beginMethod,Object state)
位于 System.Net.browser.browserhttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
位于 SilverlightApplication2.MainPage.ResponseCallback(IAsyncResult result)
解决:
在\webapps\ROOT\下增加两个文件:
crossdomain.xml和clIEntaccesspolicy.xml
------------------------------------------------------------------------
--crossdomain.xml--
------------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYstem " http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policIEs="all" />
<allow-access-from domain="*"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
------------------------------------------------------------------------
--clIEntaccesspolicy.xml--
------------------------------------------------------------------------
<?xml version="1.0" enCoding="utf-8"?> <access-policy> <cross-domain-access> <policy> <allow-from http-request-headers="*"> <domain uri="*"/> </allow-from> <grant-to> <resource path="/" include-subpaths="true"/> </grant-to> </policy> </cross-domain-access> </access-policy> 总结以上是内存溢出为你收集整理的Silverlight使用HttpWebRequest和HttpWebResponse时发生System.Security.SecurityException: 安全性错误全部内容,希望文章能够帮你解决Silverlight使用HttpWebRequest和HttpWebResponse时发生System.Security.SecurityException: 安全性错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)