SignalR IE9 Cross Domain request don't work

情到浓时终转凉″ 提交于 2020-01-16 05:33:08

问题


I'm making an application using SignalR.

The Hub is placed on one server running Windows Server 2012 with IIS 8. http://mentor.cloudapp.net/mass/rexona/previa/signalr/hubs.

The client is here: http://massdeveloperstage.com/Rexona/Site/colombia/Previa/Match?matchId=6F318A29-3400-444B-95D9-7EC41A7AD2D4

The Signalr set up looks like this:

var match;
    $(document).ready(function () {
        $.connection.hub.loging = true;
        match = $.connection.match;

    match.client.addMessage = function (message) {
        var vm = {
            avatar: message.ProfileImageLocation,
            content: message.Text,
            user: message.UserScreenName,
            obj: JSON.stringify(message)
        };
         alert(vm.obj);
   }
  $.connection.hub.url = 'http://mentor.cloudapp.net/mass/rexona/previa/signalr';

    $.connection.hub.start().done(function () {
        match.server.addToGroup("97-987-PP");
    }).fail(function () {
          //alert("fail!");
    });

Everything works perfectly in Chrome, FF, Opera and in IE10, but when it's accessed using IE9 the application fails.

Am I missing something in the set up of the connection? Do I need to enable something else on the server in order to work with IE9?

Thanks.


回答1:


I think you're trying to do CORS (Cross-Site Origin Sharing) there. It doesn't work quite like that with IE9, check this for detailed discussion, and microsoft page for the exact limitations. It is done with XDomainRequest custom object instead of XMLHttpRequest, and...

  1. The target URL must be accessed using the HTTP or HTTPS protocols
  2. The target URL must be accessed using only the HTTP methods GET and POST
  3. No custom headers may be added to the request
  4. Only text/plain is supported for the request's Content-Type header (no soap, json or encoded data types!)
  5. No authentication or cookies will be sent with the request
  6. Requests targeted to Intranet URLs may only be made from the Intranet Zone
  7. Requests must be targeted to the same scheme as the hosting page

Edit: I haven't actually ever used SignalR myself, this answer was based on CORS in general. According to a comment by @stricq, IE needs long polling enabled for this to work with SignalR, as explained in here.



来源:https://stackoverflow.com/questions/13573397/signalr-ie9-cross-domain-request-dont-work

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