今天在做一个Demo时,突然发现一个问题,在wcf服务的根目录下放置一个策略文件后
代码
<?
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 ="/" include-subpaths ="true" />
</ grant-to >
</ policy >
</ cross-domain-access >
</ access-policy >
< access-policy >
< cross-domain-access >
< policy >
< allow-from http-request-headers ="SOAPAction" >
< domain uri ="*" />
</ allow-from >
< grant-to >
< resource path ="/" include-subpaths ="true" />
</ grant-to >
</ policy >
</ cross-domain-access >
</ access-policy >
发现调用仍然会出现跨域的异常,
思前想后,找不到原因所在,后来想起来,之前在本上做tcp绑定的WCF时,我在wwwroot下放置了一个策略文件
内容是:
代码
<?
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 >
< socket-resource port ="4502-4534" protocol ="tcp" />
< resource path ="/" include-subpaths ="true" />
</ grant-to >
</ policy >
</ cross-domain-access >
</ access-policy >
< access-policy >
< cross-domain-access >
< policy >
< allow-from http-request-headers ="SOAPAction" >
< domain uri ="*" />
</ allow-from >
< grant-to >
< socket-resource port ="4502-4534" protocol ="tcp" />
< resource path ="/" include-subpaths ="true" />
</ grant-to >
</ policy >
</ cross-domain-access >
</ access-policy >
而实际上这个策略文件是为了同时使用TCP和HTTP绑定的WCF放到wwwroot下的,于是我将这个文件移除掉
注:在WCF为Silverlight提供数据服务时,我们需要在HTTP绑定类型的WCF服务根目录下放置策略文件,但是需要确保此策略文件的唯一性,如果在WWWROOT下也放置这样的文件,可能导致IIS无法正确向Silverlight递交这个策略文件。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。