0

We have web api written using MVC. On some machines when we enter url in Firefox browser shows plain text as response I want to restrict browser to show response in XML format. Is there any way to achieve this.

Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
Mangesh Kulkarni
  • 239
  • 5
  • 17

1 Answers1

0

Yes, you need to restrict your API to return only XML.

void ConfigureApi(HttpConfiguration config)
{
    // Remove the JSON formatter
    config.Formatters.Remove(config.Formatters.JsonFormatter);
}

You can find more about content negotiation in Web API here: http://www.asp.net/web-api/overview/formats-and-model-binding/content-negotiation

And here: How do I specify if I want JSON or XML in ASP.NET Web API?

Community
  • 1
  • 1
Bruno Pessanha
  • 2,874
  • 4
  • 24
  • 35
  • Hi thanks for your solution. Is it code issue or we can handle it by setting some firefox settings. Because url working fine on firefox of other machines. We are getting this issue on just one machine – Mangesh Kulkarni Dec 17 '15 at 14:18