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

Leave a Reply

preload preload preload