Summary
Isn't that cool? The ability to change the format based on the Accept
header is very handy. This way, you are able to create a Web API for many different clients: one that accepts many different formats, depending on the clients' preferences. There are still a lot of potential clients out there that don't use JSON and prefer XML or CSV.
The other way around would be an option to consume CSV data or any other format inside the Web API. Let's assume your client sends you a list of people in CSV format. How would you solve this? Parsing the string manually in the action
method would work, but it's not an easy option.
This is what ModelBinders
can do for us. Let's see how that works in the next chapter.