If I make web api call with Chrome Browser it is displaying XML data in which there is the "proper" name
Chrome is making a request from your Web Api, an attempt to do a content negotiation is taking place and if I cannot fine a formatter from you accept header ... It will try the first formatter in the list of formatters to write that response back to the client ( chrome)
Sometimes you will get json other times xml , i have refreshed my browser and seen it happen myself.
A few tricks
var json = config.Formatters.JsonFormatter; json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects; config.Formatters.Remove(config.Formatters.XmlFormatter);
Or maybe try adding in WebApiConfig.cs
config.Formatters.JsonFormatter. SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
I would personally do the 2nd approach
Return JSON response by default If you execute GET request, ASP.NET Web API framework will return response in XML, JSON or any other format depending on accept header of request. Chorme and Firefox browser has XML as default value for accept header whereas IE has JSON as default value. So if you execute request through Chrome or Firefox you will get response in XML and if you use IE you will get JSON response.
If you want your Web API should return JSON response as default you will have to configure JSON Media Type Formatter.
Open WebApiConfig.cs file from App_start folder and add that code after route configuration.
~ reference unknown what saved in a OneNote page of mine...