WebApi project is configured in the Global.asax; it is there where you will find a class named WebApiConfig
. Inside this class you will find the "Media Formatters"; the Media Formatters says whether or not your WebApi is capable of serialize/deserialize JSON System.Net.Http.Formatting.JsonMediaTypeFormatter()
, XML or any other format.
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
//...
System.Web.Http.GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
config.Formatters.Insert(0, new System.Net.Http.Formatting.JsonMediaTypeFormatter());
config.Formatters.Insert(0, new System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter());
}
}
If the JSON formatter is the first item in your list it will be your default serializer/deserializer in order to access any other format the content type of the request should explicitly indicate the desired format if it is supported it will return it and if not it will return it in the default format.
The result of the output you are seeing is entirely responsibility of the deserialization/serialization that the selected media formatter is using.