This article is a mirror article of machine translation, please click here to jump to the original article.

View: 24727|Reply: 2

[WebAPI] The webapi setting returns JSON data by default

[Copy link]
Posted on 2/17/2017 1:53:22 PM | | | |

The Web API defaults to XML format to return data

Nowadays, development is generally based on JSON format

The following configuration allows WebAPI to return JSON by default, and when you need to return XML, you only need to add a query parameter datatype=xml to return XML format data


The configuration is as follows:

1. Create a new MVC WebAPI project (Framework4.0)

2. Locate the default WebApiConfig.cs file

3. Modify the WebApiConfig.cs file






Previous:Asp.Net Mvc4 Webapi to get all the get parameters
Next:.net/c# Start ie browser with cookies [source code]
 Landlord| Posted on 6/26/2017 1:43:01 PM |
In fact, it can be done in one sentence, as follows:



 Landlord| Posted on 10/30/2020 10:36:29 AM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com