Formatters in ASP.NET MVC 6 - StrathWeb
key concepts in HTTP API development is the notion of content
negotiation (conneg). ASP.NET Web API provided first class support for
content negotiation through the use of MediaTypeFormatters.
MVC 6 ships with a bunch of formatters defined already.
Three input formatters:
– JsonInputFormatter – based on JSON.NET – XmlSerializerInputFormatter – based on XmlSerializer (in the box, but not registered by default) – XmlDataContractSerializerInputFormatter – based on DataContractSerializerSix output formatters:
– JsonOutputFormatter – based on JSON.NET –
XmlSerializerOutputFormatter – based on XmlSerializer (in the box, but not registered by default) – XmlDataContractSerializerOutputFormatter – based on DataContractSerializer – TextPlainFormatter – used to force a string into a text/plain content type – HttpNoContentOutputFormatter – used to force 204 status code for null action return – HttpNotAcceptableOutputFormatter – used to force 406
status code if no appropriate formatter can be selected to handle the
request (in the box, but not registered by default)This is a slight change from Web API which itself defined four
formatters – JSON, XML and two formatter specialized in handling form