Signalr deserializes my objects incorrectly in IIS 7.5 and Edge/IE, foreverFrame broken?

落花浮王杯 提交于 2019-12-05 07:51:00
Tomer

The problem is that using ForeverFrame, the JSON parsing is done in another frame, and the resulted array is not instanceof Array in the current frame, as described here.

In order to bypass that, SignalR (starting from 2.1.0) allows you to supply your own JSON parser to ForeverFrame:

$.connection.hub.json = {
    parse: function(text, reviver) {
        console.log("Parsing JSON");
        return window.JSON.parse(text, reviver);
    },
    stringify: function(value, replacer, space) {
        return window.JSON.stringify(value, replacer, space);
    }
};

By calling window.JSON.parse, you ensure that the array will be parsed correctly.

You will never get WebSockets with SignalR on IIS 7.5

See the docs - You will need win8/2012 Server and IIS8

Edit: Sorry for not answering the stuff about serialization, but since you mention that you want websockets I thought it was important to mention this...

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