SignalR don't resolve JsonSerializer for incoming server call

百般思念 提交于 2019-12-12 12:09:28

问题


JRawValue(https://github.com/SignalR/SignalR/blob/master/src/Microsoft.AspNet.SignalR.Core/Json/JRawValue.cs) using:

var serializer = JsonUtility.CreateDefaultSerializer();

Why not this?

var serializer = GlobalHost.DependencyResolver.Resolve<JsonSerializer>();

Is it bug?

JsonSerializer serializer = JsonSerializer.Create(settings);
serializer.Converters.Add(new SomeConverter());
GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);

SomeConverter don't work for incoming server call.


回答1:


As you noted, this is a bug in JRawValue. There is already an issue filed for this on GitHub here:

https://github.com/SignalR/SignalR/issues/3304

The submitter of the issue was able to work around it by providing their own DefaultParameterResolver that used reflection to get at the raw JSON string.

It's obviously pretty unfortunate that this is necessary. If you want, you can leave a comment on this issue indicating that it is important to you to see this issue fixed. This will increase the likelihood that the bug will be fixed in an upcoming release of SignalR.

If you do comment on the issue, it might be helpful if you left comments detailing what custom (de)serialization settings you are using on the server and what you did on the client to customize how the Hub parameters are serialized,



来源:https://stackoverflow.com/questions/26952406/signalr-dont-resolve-jsonserializer-for-incoming-server-call

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