signalR CORS - IE client gets 403 'Forbidden: JSONP is disabled'

一曲冷凌霜 提交于 2019-12-10 11:09:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!