I added config.Formatters.Remove(config.Formatters.XmlFormatter);to the method Registerfor WebApiConfig.cs in the ASP.NET Web API project. This works great to return JSON when a 404 Not Found exception is thrown. I get a message like the following:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:2034/api/dfdf'.","MessageDetail":"No type was found that matches the controller named 'dfdf'."}
Is it possible to override this message to return a custom one? If so, how is this done? I am using Web API 2.
source
share