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" />
上一篇:java – 哪个框架更好CXF或Spring-WS?


下一篇:CXF WebService的春季配置得到了java.lang.NoClassDefFoundError:javax / xml / ws / EndpointReference