Include the following line in Register() method of WebApiConfig.cs file in App_Start folder. This line of code completely removes JsonFormatter which forces ASP.NET Web API to always return XML irrespective of the Accept header value in the client request. Use this technique when you want your service to support only XML and not JSON.
config.Formatters.Remove(config.Formatters.JsonFormatter);
With this change, irrespective of the Accept header value (application/xml or application/json), the Web API service is always going to return XML.
config.Formatters.Remove(config.Formatters.JsonFormatter);
With this change, irrespective of the Accept header value (application/xml or application/json), the Web API service is always going to return XML.
No comments:
Post a Comment