And the culprit is TryReadQueryAs method of UriExtensions that just instantiates a new JsonSerializer that doesn't use global serializer settings, defined in config.Formatters.JsonFormatter.SerializerSettings. One of the consequences of this, is that I can't bind derived classes to base classes, using JSON.NET TypeNameHandling. Please fix this ASAP.
For example:
I serialize an Employee, and since i set TypeNameHandling to auto, it will add $type="Employee" to the serialized json. Then when I send that json back to some method that expects class Person, it will bind it to person (Employee properties will not get bound) and will ignore the type, because the said method doesn't use global settings(where I set TypeNameHandling). And hence uses TypeNameHandling.None.
So solution is just use the global settings when you instatiate the serializer in TryReadQueryAs method
Comments: So is there any way to work around this a.t.m? Web API is using my custom converters (WriteJson) correctly for all the content that it sends to the requesting side. It just doesn't use that same converter (ReadJson) for the parameters it gets delivered.
For example:
I serialize an Employee, and since i set TypeNameHandling to auto, it will add $type="Employee" to the serialized json. Then when I send that json back to some method that expects class Person, it will bind it to person (Employee properties will not get bound) and will ignore the type, because the said method doesn't use global settings(where I set TypeNameHandling). And hence uses TypeNameHandling.None.
So solution is just use the global settings when you instatiate the serializer in TryReadQueryAs method
Comments: So is there any way to work around this a.t.m? Web API is using my custom converters (WriteJson) correctly for all the content that it sends to the requesting side. It just doesn't use that same converter (ReadJson) for the parameters it gets delivered.