问题
We implemented SignalR 2.0 hub with CORS enabled. Javascript clients on Firefox and Chrome are running fine. IE 10 gets error 403.
Any help will be appreciated. Thank you and regards.
回答1:
While IE 10 (but not IE ≤9) should support CORS, if you find yourself needing to use JSONP you can enable it when you call MapSignalR
.
Enabling JSONP allows your SignalR app to be accessed from any origin while sending cookies/credentials. With CORS, you can limit which origins are able to access your SignalR app, whether or not cookies/credentials should be sent with cross-origin requests and more. Since JSONP cannot be configured to match the more fine-grained security policies made possible by CORS, JSONP must be enabled separately:
app.MapSignalR(new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
EnableJSONP = true
});
If you are using a PersistentConnection
replace HubConfiguration
with ConnectionConfiguration
.
You can learn more about establishing a cross-domain SignalR connection here.
来源:https://stackoverflow.com/questions/24868591/signalr-cors-ie-client-gets-403-forbidden-jsonp-is-disabled