ASP.NET-CORE 2.2 SignalR CORS [英] ASP.NET-CORE 2.2 SignalR CORS
问题描述
我对ASP.Net Core 2.2和SignalR有问题.我在asp.net核心和Angular之间使用SignalR.当我使用Asp.net core 2.0时,一切正常.但是,当我将asp.net core 2.2与相同的代码一起使用时,相同的类会出现cors错误.
I have a problem with ASP.Net Core 2.2 and SignalR. I am using SignalR between asp.net core and Angular. When i am using Asp.net core 2.0, everything work fine. But when i am using asp.net core 2.2 with same code, same classes am getting a cors error.
警告:CORS协议不允许同时指定通配符(任何)来源和凭据.如果需要支持凭据,请通过列出各个来源来配置策略.
Warning: The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time. Configure the policy by listing individual origins if credentials needs to be supported.
我该如何解决这个问题?
How can i solve this problem?
谢谢
推荐答案
当我使用此cors配置问题时,此问题已解决.谢谢
When i am using this cors configuration problem is solved. thanks
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder
//.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()
.SetIsOriginAllowed((host) => true) //for signalr cors
);
});
这篇关于ASP.NET-CORE 2.2 SignalR CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!