Silverlight 跨域访问
时间:2011-01-30 来源:dudulang971
Silverlight提供了两种方式实现不同域之间的访问。分别是
(1)Silverlight 客户端访问策略文件 (clientaccesspolicy.xml),
客户端访问策略文件格式
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/Resource/" include-subpaths="true"/>
</grant-to>
</policy>
<policy >
<allow-from http-methods="*">
<domain uri="www.XX.com"/>
</allow-from>
<grant-to>
<resource path="/Resource/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
跨域策略文件格式
<?xml version="1.0"?>需要特别注意的是clientaccesspolicy.xml需要放在服务器的根目录下。
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/ headers="SOAPAction"
secure="true">
</cross-domain-policy>
相关阅读 更多 +