SignalR 在 IE10 中抛出此错误:
SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status code 500, Internal Server Error
在Chrome中,一切都按预期运行。我使用的代码:
<!--Reference the SignalR library.-->
<script src="@Url.Content("~/Scripts/jquery.signalR-2.1.2.min.js")"></script>
<!--Reference the autogenerated SignalR hub script-->
<script src="@Url.Content("~/signalr/hubs")"></script>
<!--Add script to update the page and send messages.-->
<script type="text/javascript">
$(function () {
//Declare a proxy to reference the hub.
var chat = $.connection.chatHub;
chat.on('broadcastMessage', function (userId, conversationId, message) {
NewMessages();
});
$.connection.hub.start();
});
</script>
这是集线器:
public class ChatHub : Hub
{
public void Send(string userId,string conversationId, string message)
{
//Call the broadcastMessage method to update clients.
Clients.All.broadcastMessage(userId, conversationId,message);
}
}
服务器方法"发送"得到正确调用,但客户端"broadcastMessage"没有。我做了一些阅读,IE10支持SignalR。有人知道为什么这不起作用吗?
chat.client.broadcastMessage = function(userId, conversationId, message)
{
NewMessages();
}