简体   繁体   English

WCF REST服务:允许跨域访问

[英]WCF REST Service : Allowing Cross Domain Access

I am hosting a RESTful WCF service in an azure Web Role. 我在一个Azure Web角色中托管一个RESTful WCF服务。 This service is to be consumed by jQuery. jQuery将使用此服务。

How do I allow cross domain access to this service? 如何允许跨域访问此服务?

Thanks 谢谢

I know this is an old question, but I just came across a similar issue and thought the following may help someone stumbling across this question. 我知道这是一个古老的问题,但我遇到了一个类似的问题,并认为以下内容可能会帮助遇到这个问题的人。 In visual studio, add a new xml file called clientaccesspolicy.xml to your Web Role project with the following contents: 在visual studio中,将具有以下内容的名为clientaccesspolicy.xml的新xml文件添加到您的Web Role项目中:

<?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>

To restrict access, edit the <domain uri="*"/> to whatever you need to. 要限制访问,请将<domain uri="*"/>编辑为所需的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM