SignalR cross domain not working on browsers other than IE10

瘦欲@ 提交于 2019-12-07 04:10:25

问题


I am writing a web app using SignalR cross domain communication. I am using the latest version of SignalR, 1.0.1. Following is the code in the jQuery's document ready event:

var connection = $.hubConnection(url);
  var proxy = connection.createHubProxy(hubName);

  connection.start().done(function () {
    proxy.invoke('serverMethod');
  });

I tried running the application on Opera, Firefox, Chrome and IE 10. My OS is Windows 7. It works well on IE 10 and doesn't work on other browsers. I changed mode of IE using developer tools to IE 9, and it stopped working. The same code works on all browsers if I use SignalR version 0.5.3.

In developer tools of the browser, I found the following HTTP status code in response of negotiation request: "HTTP/1.1 403 Forbidden".

Am I missing anything here? What is the reason because of which it is breaking on browsers other than IE 10?


回答1:


Ensure that in your MapHubs call that you enable cross domain.

RouteTable.Routes.MapHubs(new HubConfiguration() { EnableCrossDomain = true });

When testing cross domain locally IE10 has an interesting feature that treats any localhost port as not being cross domain.



来源:https://stackoverflow.com/questions/15312077/signalr-cross-domain-not-working-on-browsers-other-than-ie10

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