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

解决方法:

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

 

 打开Webservice的Web.config文件

  <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>
  </system.webServer>

就可以解决跨域问题了

 

上一篇:Python多线程共享变量资源竞争问题


下一篇:Navicat 连接 mysql 出现Client does not support authentication protocol requested by server解决方案