Remove or Disable XML Formatter in ASP.NET WEB API

10 Feb

Remove XML Formatter in ASP.NET WEB API

In this post we can learn how to remove the default xml formatter in ASP.NET Web API. By default ASP.NET Web API returns XML output.

Write the following code in the App_Start/WebApiConfig.cs

public static class WebApiConfig
 public static void Register(HttpConfiguration config)
   //Remove the XM Formatter from the web api

   name: "DefaultApi",
   routeTemplate: "api/{controller}/{id}",
   defaults: new { id = RouteParameter.Optional }

Leave a Reply

Your email address will not be published. Required fields are marked *