利用asp.net core 3.1 开发了一个webapi,部署在IIS时,出现如下错误:

Access to fetch at 'XXXXX' from origin 'http://xxxxxxx:xxxx' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

在Startup.cs 的ConfigureServices和Configure都进行了跨域设置,具体的设置,微软官方文档说明的比较详细。

https://docs.microsoft.com/zh-cn/aspnet/core/security/cors?view=aspnetcore-3.1

部署在IIS依然有跨域问题,还是在上面微软官方文档里面找到了解决办法:需要安装IIS Cors跨域模块。

asp.net core 3.1 webapi 跨域解决办法

程序内部异常或错误也会报出跨域的问题。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-07-17
  • 2021-10-16
  • 2022-12-23
  • 2022-02-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2021-09-24
相关资源
相似解决方案