异常代码发生在第二句
HttpWebRequest request = result.AsyncState as HttpWebRequest;
WebResponse response = request.EndGetResponse(result);
提示信息:
System.Security.SecurityException ---> System.Security.SecurityException: 安全性错误。
位于 System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(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"?>