Ale*_*dre 10 c# asp.net-core asp.net-core-signalr asp.net-core-2.2
为了通过SignalR从任何来源连接到ASP.NET Core 2.1服务器,我们必须按以下方式配置管道:
app.UseCors (
builder => builder
.AllowAnyHeader ()
.AllowAnyMethod ()
.AllowAnyOrigin ()
.AllowCredentials ()
)
Run Code Online (Sandbox Code Playgroud)
根据该文档,ASP.NET Core 2.2不再允许AllowAnyOrigin和AllowCredentials的组合,那么解决方案是什么?而SignalR Core始终在XMLHtppRequest中发送withCredentials:true。
我需要的是,从任何地方开始,无需证书,我们的用户都可以连接到SignalR集线器。
Ale*_*dre 23
有一种解决方法,更改AllowAnyOrigin为SetIsOriginAllowed:
app.UseCors(builder => builder
.AllowAnyHeader()
.AllowAnyMethod()
.SetIsOriginAllowed(_ => true)
.AllowCredentials()
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2426 次 |
| 最近记录: |