ASP.Net web API Help Page - no content

4.8k Views Asked by At

I installed the package from NuGet, uncommented the line from HelpPageConfig.cs-

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

I've set the same file under Properties->Build->XML documentation file, Added a new Global.asax.cs file in which I call for registration for all the areas under Application_Start method:

protected void Application_Start(object sender, EventArgs e)
{
     AreaRegistration.RegisterAllAreas();
}

I've added some summary for some of my controllers:

public class IncidentsController : ApiController
{
     /// <summary>
     /// this is the summary
     /// </summary>
     /// <param name="incidentId">this is incidentId</param>
     /// <returns>it returns something</returns>
     [Route("{incidentId}")]
     [HttpGet]
     public object GetIncidentById(int incidentId)
     {
            return Incidents.SingleOrDefault(i => i.id == incidentId);
     }
}

when i run the webpage and go to '/help' the only thing i see is

ASP.NET Web API Help Page

Introduction

Provide a general description of your APIs here.

and an empty page after that...

I tried to debug that and in HelpController.cs in:

public ActionResult Index()
{
            ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
            return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
}

I get no ApiDescriptions.

what am I missing? I'll appreciate any help!

2

There are 2 best solutions below

0
On

Have you mapped you XMl Path right ?

Have you added summary to your methods ? /// /// Gets some very important data from the server. ///

This should help Have you checked WebApi Help Page Description

5
On

I was able to solve this by adding GlobalConfiguration.Configure (WebApiConfig.Register); in my Application_Start () method. Because my application uses OWIN I was registering my APIs only in Startup.Configuration (IAppBuilder app).