【问题标题】:signalR CORS - IE client gets 403 'Forbidden: JSONP is disabled'signalR CORS - IE 客户端获取 403 'Forbidden: JSONP is disabled'
【发布时间】:2014-07-21 15:12:38
【问题描述】:

我们实现了启用了 CORS 的 SignalR 2.0 集线器。 Firefox 和 Chrome 上的 Javascript 客户端运行良好。 IE 10 收到错误 403。

任何帮助将不胜感激。 谢谢和问候。

【问题讨论】:

    标签: signalr cors http-status-code-403


    【解决方案1】:

    虽然 IE 10(但不是 IE ≤9)应该支持 CORS,但如果您发现自己需要使用 JSONP,您可以在调用 MapSignalR 时启用它。

    启用 JSONP 允许在发送 cookie/凭据时从任何源访问您的 SignalR 应用。使用 CORS,您可以限制哪些来源能够访问您的 SignalR 应用程序,是否应使用跨域请求发送 cookie/凭据等等。由于无法将 JSONP 配置为匹配 CORS 实现的更细粒度的安全策略,因此必须单独启用 JSONP:

    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
    });
    

    如果您使用的是PersistentConnection,请将HubConfiguration 替换为ConnectionConfiguration

    您可以了解更多关于establishing a cross-domain SignalR connection here的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-30
      • 2021-06-01
      • 2015-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多