Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net web API Help Page - no content

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!

like image 929
Sirguley Von-Tuck Avatar asked Aug 25 '15 06:08

Sirguley Von-Tuck


1 Answers

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).

like image 93
kdubau Avatar answered Oct 11 '22 02:10

kdubau