Use Visual Studio to create a new ASP. NET Web API project, run directly, view the help documentation to see the following API helper instructions
How to display the description in description.
1. Open Controllers=>valuescontroller, add comments for each API (Summary)
Public classvaluescontroller:apicontroller{/// <summary> ///GET api/values/// </summary> /// <returns></returns> Publicienumerable<string>Get () {return New string[] {"value1","value2" }; } /// <summary> ///GET API/VALUES/5/// </summary> /// <param name= "id" ></param> /// <returns></returns> Public stringGet (intID) {return "value"; } /// <summary> ///POST api/values/// </summary> /// <param name= "value" ></param> Public voidPost ([Frombody]stringvalue) { } /// <summary> ///API/VALUES/5/// </summary> /// <param name= "id" ></param> /// <param name= "value" ></param> Public voidPut (intID, [frombody]stringvalue) { } /// <summary> ///API/VALUES/5/// </summary> /// <param name= "id" ></param> Public voidDelete (intID) {}}
2. Open the Project's property page =>build, check output=>xml documentation file: and enter the path to the document that holds the project notes.
3. Modify the following code
Areas=>helppage=>app_start=>helppageconfig.cs, cancel the line comment
Config. Setdocumentationprovider (New Xmldocumentationprovider (HttpContext.Current.Server.MapPath ("~/app_data/ Xmldocument.xml ")));
Note that the path must be the same as the path you configured above.
4. Rebuild the project and generate the Xmldocument.xml file under App_Data
5. Check the help page again to see that the API comments have increased.
ASP. NET Web API generates help documents based on code comments