Intro In this blog, I intend to provide a simplified how-things-work and how-to-change-the-behavior. It is not intended as a deep dive into content negotiation.
Since Web API 1 controller code can return an object of an arbitrary type and the framework will send it as JSON or XML to the client. The process of picking the output format is called “content negotiation”. The basic rules can be described simply as:
1. The framework will attempt to return the format that the client asked for using the Accept header.
2. In absence of a specific format requested or inferred, the default format is JSON.
3. If the format the client asked for is not available the framework will return the default format JSON. (Example: accept header was application/DoesNotExistFormat)
MVC 6 combined Web API and MVC into a single framework. Although content negotiation was revamped, the basic rules have not changed. There are s ...
Go to the complete details ...