martedì 10 luglio 2012

Web Api default xml formatter.

The default formatter in the Mvc web api is an XML formatter.
To disable it, it's necessary to remove it from the default formatters.
In the Global.asax.cs (if we talk c#) you should add these lines of code:

// The Web API Configuration Object
var config = GlobalConfiguration.Configuration;
// Remove the XML Formatter
var xmlFormatter = config.Formatters
.Where(f =>
return f.SupportedMediaTypes.Any(v => v.MediaType == "text/xml");

if (xmlFormatter != null)

Nessun commento:

Posta un commento