Jan 13

I like to use OWIN with Web API unfortunately Web API Help pages is MVC and actually doesn’t work first time with OWIN, so much so I asked a Stack Overflow question about it (which I ended up answering myself). You can get it working on IIS with minimal effort, but not on self host this is because MVC requires (pre vNext) System.Web.

At first I gave up and tried Swagger for my docs, but I came back to Web API Help Pages. What I like about Web API Help Pages is at it’s heart it’s just a set of Razor templates. And for me using Razor templates is about as easy as it gets. So I thought ‘How hard can it be to make Web API help pages work with self host?’ A quick Google revealed that Yao has already managed to get Web API Help Pages working on self host using T4 templates, so if I do something similar but using Razor I’m in business.

Pretty quickly I managed to get Yao’s example working with RazorEngine. Next I thought what can I do to improve Web API Help Pages, how would I want it to work? I settled on it being OWIN middleware configured using extension methods, I also settled on removing as many dependencies (System.Web) as I could, especially on any front-end frameworks. My thinking here is that Web API Help Pages should provide you with the templates so you can customize it with any front-end framework you want. So now you know the background below is a guide to using what I have put together. Note this works with a Microsoft.Owin.Host.SystemWeb (IIS) or Microsoft.AspNet.WebApi.OwinSelfHost (Katana/HttpListener) hosted Web API.

Head over to the GitHub repo for everything you need for getting started

3 Responses to “Introducing DalSoft.WebApi.HelpPage – Help Pages for ASP.NET Web API working on OWIN self host”

  1. aremes says:

    I’ve been struggling with this for a while now, and i often came back to your question on SO. i just saw this update to it, tried it out, works superb! finally, no need to mess with IIS. Thank you! Thank you very very much!

  2. bocha29 says:

    Hello DalSoft, i am having an issue when running my project with your middleware. I am having a Could not resolve template api.cshtml error when clicking on help page link. Do you know what or how can i fix it?

  3. peecee says:

    Hi DalSoft, this seems to work great, the only issue is the ‘Help Page Home’ link (in the parameters pages), does not include the virtual directory in the link. Ie it is set as “http://localhost/help”, but I need it to be “http://localhost/myapi/help.

    I can see this is set via the ViewBag.HelpRoute but not sure how to set this to include whatever virtual directory is being used (which could be different per deployment)

    Any help for this would be great.

    Cheers

Leave a Reply

preload preload preload