asp.net web api - How to set default serializer to JSON without removing XML serializer -
Is it possible to make JSON default serializer in WebApi2 without removing XMLA?
We tried to order the XmlSerializer back, but brought Jason Serializer to face but nothing is changing.
By default json format should "win" Generators are defining what the formatter is "Win" is going.
- Is JSON formatter also able to write your type, you want to verify that first if you use the Data Controlled Serializer, it is slightly more selective, json.net version Is behaving well (and it is the default).
- If you have no accept header, the content negotiator still looks at the content type of the request and will like to send your request XML?
If the content of these two questions is not there, the content negotiator (
DefaultContentNegotiator ) will now end with XML and JSON formatters and call
SelectResponseMediaTypeFormatter < / Code>
Here originally it will select the first formatter in the list (I'm saying it with caviat because it is a bit more complicated than it) so that you can verify your list Really ordered again as you expected it was.
Finally and I do not think you need to go there because you should decide the above content, you can always replace the IContant interlocutor and overrideResportsMediaType format if you have more than one format, So you choose Jason one.
Comments
Post a Comment