SignalR/SignalR — Issue #138: SignalR should use IJsonStringifier for message data and not message containers
Author: kamranayub
Created: 2012-01-16 03:03:43+00:00
State: open

My specific case is this: I need to make my view models that I pass back from my Hub serialize using JSON.NET. I specfically want to use the `CamelCasePropertyNamesContractResolver` so that my property names go from `Id` to `id` for consumption on the client side.

Unfortunately, binding my new serializer causes SignalR to use it on *every* object passed to the client rather than **only** message data:

```
public class JsonNetStringifier : IJsonStringifier {
public string Stringify(object obj) {
return JsonConvert.SerializeObject(obj, Formatting.None, new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
ContractResolver =
new CamelCasePropertyNamesContractResolver()
});
}
}
```

Here is the JSON result from **negotiate**:

```
{"url":"/signalr","clientId":"194d19cf-219b-405e-9ed2-d5309d098022"}
```

Note that Url and ClientId are now camel cased. This causes the connection routine to break as the JS expects PascalCased names.