ASP.NET WEB API remove a Formatter

Recently I started on ASP.NET WEB API, created some code for demo purpose. I realized that the response can be either XML or JSON based on request header. To give it a try I opened the web API in IE and Mozilla, and yes IE showed JSON result and Mozilla showed XML result.
So now the question is- can I see the same results in both the browsers irrespective of the request header value?

Yes, this can be done,

In Global.asax Application_Start() add below line before ConfigureApi(GlobalConfiguration.Configuration);

GlobalConfiguration.Configuration.Formatters.JsonFormatter.SupportedMediaTypes.Clear();

So now the results in both the browsers are same that is- XML.

Up Next
    Ebook Download
    View all
    Learn
    View all
    F11Research & Development, LLC