ajax跨域请求webservice webconfig配置

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>

</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/>
<add name="Access-Control-Allow-Headers" value="x-requested-with,content-type"/>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<modules>
<add name="MyHttpModule" type="WebServiceDemo.MyHttpModule"/>
</modules>
</system.webServer>

如果想选定的网站可能跨域访问,修改配置如下

 

<add name="Access-Control-Allow-Origin" value="http://domain1.com, http://domain2.com" />
posted @ 2019-07-20 07:40  Javi  阅读(429)  评论(0编辑  收藏  举报