这几天想用silverlight访问网站的xml文件,一直提示安全性错误,搜索了很多,终于解决了。
得在站点根目录添加一个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 include-subpaths= "true" path= "/interface" />
< /grant-to>
< /policy>
< /cross-domain-access>
< /access-policy>
< access-policy>
< cross-domain-access>
< policy>
< allow-from http-request-headers= "*">
< domain uri= "*" />
< /allow-from>
< grant-to>
< resource include-subpaths= "true" path= "/interface" />
< /grant-to>
< /policy>
< /cross-domain-access>
< /access-policy>
其中/interface 为需要访问的文件所在的路径,并且这个文件需要放在将要访问的站点根目录。
我看网上很多写的include-subpaths="false"。我试了,貌似不行,也不知道是什么原因。
更多参考资料:
http://silverlightchina.net/html/tips/2009/0916/184.html
http://silverlightchina.net/html/tips/2010/0107/563.html
这个微软详细说明:
http://msdn.microsoft.com/zh-cn/library/cc645032(v=vs.95).aspx
备忘。
本文来自BlueBreeze的博客,原文地址:http://www.cnblogs.com/BlueBreeze/archive/2011/08/30/silverlight.html