C#WebService 出现No 'Access-Control-Allow-Origin' header is present on the requested resource

C#WebService 出现No 'Access-Control-Allow-Origin' header is present on the requested resource

解决办法:

在config里面加上以下代码即可解决

1 <system.webServer>  
2    <httpProtocol>  
3        <customHeaders>  
4           <add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/>  
5            <add name="Access-Control-Allow-Headers" value="x-requested-with"/>  
6           <add name="Access-Control-Allow-Origin" value="*" />//表示允许所有来源进行跨域访问  
7        </customHeaders>  
8   </httpProtocol>  
9 </system.webServer> 

 

posted @ 2017-11-01 09:54  lilyshy  阅读(1937)  评论(0编辑  收藏  举报