在 MVC 项目中,我在集线器上有一个与此类似的方法:
public string Foo() { return DoCrazyThingThatReturnsJson(); }
不幸的是 SignalR (或其他东西)接受编码的 JSON 字符串并愉快地对其进行编码,然后返回它,所以浏览器就像 LOLWTF 一样。有没有办法跳过第二次编码?
看着这里 https://github.com/SignalR/SignalR/blob/2.2.0/src/Microsoft.AspNet.SignalR.Core/Infrastructure/Connection.cs#L204:
我们假设任何 ArraySegment 都已经是 JSON 序列化的
it seems like something like this may work https://github.com/SignalR/SignalR/blob/master/tests/Microsoft.AspNet.SignalR.Tests.Common/Connections/PreserializedJsonConnection.cs (note that I haven't tried it, so no promises):
string jsonString = ...; // your serialized data
var jsonBytes = new ArraySegment<byte>(Encoding.UTF8.GetBytes(jsonString));
Clients.Caller.sendJson(jsonBytes);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)