Asp.net CORS启用不适用于/ token

时间:2018-06-29 09:35:09

标签: c# asp.net cors cross-origin-read-blocking

我正在asp.net Web api项目中工作。我已经使用System.Web.Http.Cors NuGet包启用了CORS,如下所示。

在“ WebApiConfig.cs”中添加

EnableCorsAttribute cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);

之后,在“公共局部类启动”中添加了Startup.Auth.cs

[EnableCors(origins: "*", headers: "*", methods: "*")]

但是chrome仍然会出错。

Failed to load http://localhost:7463/token: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

 Cross-Origin Read Blocking (CORB) blocked cross-origin response http://localhost:7463/token with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

0 个答案:

没有答案