With SignalR 2, you can use DepandyResolver to replace the Json.Net serializer. To solve the problems with the reference contour in my application, I used the following:
protected void Application_Start() { var serializerSettings = new JsonSerializerSettings(); serializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; serializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects; var serializer = JsonSerializer.Create(serializerSettings); GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer); }
If you are using hubProxy on the client, you will need the same settings:
hubProxy.JsonSerializer.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; hubProxy.JsonSerializer.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
source share