WebApi Help Page Description

asp.net Mvcasp.net Web-Api

asp.net Mvc Problem Overview


What populates the Webapi method's description on the helper page and the introduction paragraph?

enter image description here

asp.net Mvc Solutions


Solution 1 - asp.net Mvc

According to this article you can use XML documentation comments to create the documentation. To enable this feature, open the file Areas/HelpPage/App_Start/HelpPageConfig.cs and uncomment the following line:

config.SetDocumentationProvider(new XmlDocumentationProvider(
    HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

Now enable XML documentation. In Solution Explorer, right-click the project and select Properties. Select the Build page.

Under Output, check XML documentation file. In the edit box, type “App_Data/XmlDocument.xml”.

Add some documentation comments to the controller methods. For example:

/// <summary>
/// Gets some very important data from the server.
/// </summary>
public IEnumerable<string> Get()
{
    return new string[] { "value1", "value2" };
}

/// <summary>
/// Looks up some data by ID.
/// </summary>
/// <param name="id">The ID of the data.</param>
public string Get(int id)
{
    return "value";
}

Solution 2 - asp.net Mvc

To view the description you need to follow this :

  1. Every action in your Customer controller must have a XML documentation

  2. Open the properties of the project that contains your controllers and enable XML documenation like this : enter image description here

  3. In the Register method for HelpPageConfig class ( Areas/HelpPage/App_Start/HelpPageConfig.cs) uncomment the line 19 and don't forget to change the file path like this :

    config.SetDocumentationProvider(new XmlDocumentationProvider(
        HttpContext.Current.Server.MapPath("~/App_Data/MvcApplication4.XML"))
    );
    

This all you must do. Last thing is to include the file created in App_Data in your project so the file will be deployed in production.

Solution 3 - asp.net Mvc

For those of you using VB.NET, you seem to have to do it a little differently.

You have to go to the "Compile" tab (there is no Build tab) for the Web API project, then ensure "Generate XML documentation file" checkbox is checked.

enter image description here

The output actually gets put in /bin/{projectName}.xml, so now you have to change the SetDocumentationProvider call to point to the path "~/bin/{projectname}.xml" (obviously, replace {projectname} with your actual project name).

This seems smelly, so please let me know if anybody finds a different way to do it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionheymegaView Question on Stackoverflow
Solution 1 - asp.net MvcMd Nazmoon NoorView Answer on Stackoverflow
Solution 2 - asp.net MvcCodeNotFoundView Answer on Stackoverflow
Solution 3 - asp.net MvcChrisCView Answer on Stackoverflow