我正在将SignalR-Service迁移到新的AspNetCore.SignalR(2.1预览版),现在我遇到了CORS的问题.我永远不会从同一个来源访问该服务,所以我需要一般禁用CORS.
我有以下的CORS政策
services.AddCors(
options => options.AddPolicy("AllowCors",
builder =>
{
builder
.AllowAnyOrigin()
.AllowCredentials()
.AllowAnyHeader()
.AllowAnyMethod();
})
);
Run Code Online (Sandbox Code Playgroud)
(来自不同来源的我的WebApi-Controller呼叫在这些策略下工作正常)
使用SignalR for AspNetCore(AspNetCore.SignalR.Server)的旧预览包我没有任何问题,但现在,我的测试客户端得到了一些http-405,这似乎是CORS的一个问题.
SignalR可能有额外的CORS配置,还是我需要允许其他东西?
编辑:我创建了一个新的/干净的示例项目,没有任何特殊的中间件来检查如果错误发生在这里,它确实发生.
示例WebApplication | startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using WebApplication1.HUBs;
namespace WebApplication1
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(
options => options.AddPolicy("AllowCors",
builder => …Run Code Online (Sandbox Code Playgroud)