问题
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