【发布时间】:2020-03-27 11:58:56
【问题描述】:
从 Asp.net core 2.2 迁移到 3.1 后,控制台出现以下错误
Access to XMLHttpRequest at 'someuri/negotiate?negotiateVersion=1' from
origin 'http://localhost:4208'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested
resource.
还有下面SignalR的配置:
app.UseCors(Constants.Policy);
app.UseAuthentication();
app.UseEndpoints(
endpoints =>
{
endpoints.MapHub<SomeHub>("/ws/someuri");
});
我已添加以下政策:
options.AddPolicy(Constants.Policy,
p =>
p.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()
.WithOrigins("http://localhost:4208"));
但这并没有帮助。
【问题讨论】:
标签: asp.net signalr asp.net-core-3.1