解决方法:

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

 

 

 打开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>

就可以解决跨域问题了

 

相关文章:

  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
猜你喜欢
  • 2021-07-01
  • 2021-06-29
  • 2021-11-09
相关资源
相似解决方案