简体   繁体   English

一段时间不活动后,SignalR JavaScript集线器方法未在IE中触发

[英]SignalR javascript hub method not firing in IE after a period of inactivity

I have a SignalR (v0.5.2) Hub sending a message to a JavaScript client. 我有一个SignalR(v0.5.2)集线器,它向JavaScript客户端发送消息。

c# C#

public Task SendData(ClassName classData){
    return Clients["groupid"].renderData(classData);
}

javascript javascript

var _client = $.connection.myHub;
_client.renderData = function(data){
    /* do stuff */
};

$.connection.hub.start({ transport:activeTransport }, function(){ });

All works fine except that after a period of inactivity in IE9, the JavaScript method fails to run. 除了在IE9中处于非活动状态一段时间之后,JavaScript方法无法运行之外,其他所有方法都工作正常。

I have looked at the Response Body of the /signalr/connect?transport=foreverFrame network log within IE9 developer tools and can see that I am receiving the message: 我在IE9开发人员工具中查看了/signalr/connect?transport=foreverFrame网络日志的响应/signalr/connect?transport=foreverFrame ,可以看到我收到了以下消息:

<script>r(c, {"MessageId":"54","Messages":[{"Hub":"myHub","Method":"renderData","Args":[....]]}],"Disconnect":false,"TimedOut":false,"TransportData":{"Groups":["LiveBid.999"]}});</script>
<div>{"MessageId":"54","Messages":[{"Hub":"myHub","Method":"renderData","Args":[....]]}],"Disconnect":false,"TimedOut":false,"TransportData":{"Groups":["LiveBid.999"]}}</div>

Yet the JavaScript method never fires? 但是JavaScript方法永远不会触发?

After a lot of time spent debugging this, it turns out that it is the version of my Modernizr file which is causing the problem. 经过大量时间调试后,原来是导致问题的原因是我的Modernizr文件的版本。

I am not massively familiar with how the inners of Modernizer work, however I have created a custom version of the file that only has css/html5 elements features, and this currently seems to work with SignalR and foreverFrame. 我对Modernizer的内部工作原理不是很熟悉,但是我创建了一个仅具有css / html5元素功能的文件的自定义版本,目前似乎可以与SignalR和foreverFrame一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM