The Web API returns JSON data, and the webapi returns json data.
For new Web API users, do not ignore ApiController.
In web APIs, if the return value of a method is an object, JSON data is automatically returned, for example:
The returned value is as follows:
{& Quot; Content & quot;: true, & quot; StatusCode & quot;: 200, & quot; RequestMessage & quot;: & quot; sample string 2 & quot "}
This is the defined Response class.
Public class Response <T> // where T: class {public T Content {get; set;} public HttpStatusCode StatusCode {get; set;} public string RequestMessage {get; set ;}}
There is another problem with the web API. It may be that I am too comfortable. If the newly created controller is not carefully viewed, the MVC4 or MVC5 controller will be selected by default, this will cause HelpPage to fail to display interfaces on the API page. Just modify the Controller to inherit the ApiController.