Web API Return Pure Json Data

Web API Return Pure JSON Data

When working with Web API, it is important to return data in the response in form of JSON Data so that a Client consuming the data won't do much to clean the data. You could append or define a format of data expected to be returned in the Http Header when making a request, however, in this case, we want to return pure JSON and make it a Web API standard.


Please Login to see the rest of the answer
Answer:

Just add the code below in the WebApiConfig.cs file and problem solved:
//Remove xml formatter
            config.Formatters.Remove(config.Formatters.XmlFormatter);

Write an Article
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2022 - ErnesTech - Privacy