I\'ve written two ASP.NET Web API applications this week which both contain a single simple controller; I\'ve tweaked each to get them to work, include exceptions, and so on
Two well written answers. I will explain the default behavior in this answer.
What will be the default behavior ? i.e if "Accept: */*"
From official docs. (go through this doc completely to understand end to end)
If there are still no matches, the content negotiator simply picks the first formatter that can serialize the type.
To summarize, following is the order.
Application looks for the Accept
header. If accept header value contains specific format, it will use that formatter.
if */*
is given for Accept
header, then the first item in config.Formatters
list will be choosen.
Bonus point: If you have not edited config.Formatters
, then default will be json value.