ASP.NET Web API Help Page for self-hosted services

This sample shows how to get the ASP.NET Web API Help Page working on self-hosted services.

C# (432.8 KB)
 
 
 
 
 
(0)
4,694 times
Add to favorites
12/21/2012
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • XML comments for controllers defined in separate assemblies not read
    4 Posts | Last post January 28, 2015
    • Hello Yao,
      I have various Controllers defined in separate assemblies for my self-hosted Web API. I successfully integrated the Self-host Web API Help Page projects in my solution and can see the Help Page hosted.
      
      However, none of my XML comments from Controllers defined in different assemblies are showing up on the Help Page. Is this only a problem with the Self-host version of Help Page project or this is not supported in the Web hosted API Help Page either?
      
      Can you please help with the best approach I can adopt to make this work. I really like this Help Page project and would like to use it in my solution.
      
      Also, I noticed that when I use config.SetActualResponseType() for Controllers defined in separate assemblies the entire Controller gets removed from the Help Page. Why would that be?
      
      Thanks,
      Sid.
    • I just tested and found that the same problem exists even with Web hosted Help Page solution. If the Controller is in a separate project (Class library) referenced by Web API, the XML comments are not shown on the Help Page which just shows "No documentation available"
      
      Can you please suggest an approach to make the Help Page work with Controllers defined in external libraries?
      
      Thanks,
      Sid.
    • Hi Yao,
      Any idea if this Help Page solution would work with Controllers defined in separate assemblies? I'd really appreciate a response on this matter.
      Thanks,
      Siddharth.
      
    • Hey Sid,
      
      It's almost 2 years later, but this is something that I found fairly easy to do.  You will need to merge the XML comments from each of the projects/DLLs into the single comment file that the help system processes.  Remove the <assembly> elements and merge everything in <doc>/<members> from each project/DLL into the comment file that will be parsed.  You only need to do this update/merge when the interfaces change, and then only when you really need to see it in the help pages.
      
      Take it easy,
      Will
  • T4 Template Vs Razar
    2 Posts | Last post February 18, 2013
    • Is there any reason behind using T4 template. Can you Please let how the views and code look like if we use cshtml?
      
      We have 3 web api projects and want to generate help files for each our CD Build .. Looking to create Help Page generation module and get the  api dll reference from the project references and generate the help files!! Can you please let me know the best approach to generate help files and host on the server on a separate port. our nightly builds need to generate help files for each api and host them.
      
      (or) Making home page is a help page for dev and qa  .. for UAT and prod we want disable the help page screen
      Can you please guide me with best approach.
      
      Thanks in advance
      v-ratall@microsoft.com 
      ramnaresh_t@yahoo.com
    • The reason I used T4 is because it's simple and works well without ASP.NET MVC. To use cshtml, you'll need to host the Razor outside of ASP.NET MVC and do some work to support the @Html helpers. Technically it's possible but I haven't tried it myself.
      Check out my other blog post about design-time generation of help page. It should have the answer to your question about generating help files.
      http://blogs.msdn.com/b/yaohuang1/archive/2013/01/20/design-time-generation-of-help-page-or-proxy-for-asp-net-web-api.aspx
  • Html page with ajax web api call
    2 Posts | Last post December 21, 2012
    • I downloaded and ran the code, it works great as described! we want to make our MVC4 web api project self-hosted and I am doing some investigation, suppose we have a html page with web api ajax call, and map the returned data to knockout view model, it works with web hosting, do you think it can also work with self-hosting? I spent two days on this and have not yet been able to get it working, if you can give some ideas or have a sample App, that would be very much appreciated, thanks!
    • As long as the request is made in the same origin, I don't see why it wouldn't work. Where is your HTML page hosted?