我已经构建了一个简单的SignalR中心,它位于WebAPI服务中,我在WebAPI和SignalR中都包含了所有必需的CORS属性。我的WebAPI端点都按预期工作,但SignalR不是。SignalR响应覆盖头文件
我试过所有我能想到的和所有我可以在网上找到但没有任何工作,我已经尝试this answer和this other到无解。
我SignalR扩展方法看起来像这样
public static IAppBuilder UseSignalrNotificationService(this IAppBuilder app)
{
var config = new HubConfiguration();
config.Resolver = new HubDependencyResolver();
config.EnableDetailedErrors = true;
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(config);
return app;
}
而且我甚至尝试使用Web.config文件中添加对所有请求响应头,但我百达得到同样的错误:
XMLHttpRequest cannot load https://MyApplicationServer/notifications/signalr/negotiate?clientProtocol=1.5&access_token= &connectionData=. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'MyOriginService' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
我试图改变SignalR的CORS策略指定的起源没有结果,一些奇怪的与请求和其头发生 – evilpilaf