Note: Read the comments of this answer, it can produce a XSS Vulnerability if you are using the default error handing of WebAPI
I just add the following in
App_Start / WebApiConfig.cs class in my MVC Web API project.
config.Formatters.JsonFormatter.SupportedMediaTypes .Add(new MediaTypeHeaderValue("text/html") );
That makes sure you get JSON on most queries, but you can get
XML when you send
If you need to have the response
application/json please check Todd's answer below.
NameSpace is using