How to add Help Pages to ASP.NET Web API Services – Dan Wahlin
How to add Help Pages to ASP.NET Web API Services – Dan Wahlin
In a previous post I discussed the fundamentals of using the new ASP.NET Web API to expose JSON data to Ajax-enabled clients. One of the challenges with RESTful services exposed by ASP.NET Web API, Node.js, WCF, and others is that consumers of the service don't know what to expect from it unless documentation is provided or unless they manually call the service and analyze the data that's returned. Fortunately, Microsoft has added a new help page feature to make it much easier to understand what data a service provides.
To get started adding help pages into ASP.NET Web API projects you can install the latest Visual Studio Fall 2012 Update Microsoft ASP.NET – Fall 2012 Update and create a new Web API project or use the help page Nuget package to add the functionality into an existing project:
For now you'll have to select "Include Prerelease" from the dropdown in order to see it in the NuGet Package Manager but that'll change in the near future as it moves into a final release.
After adding help page functionality into an ASP.NET MVC project (note that you can use ASP.NET Web API and the help page feature in ASP.NET Web Forms projects as well), you'll see an Areas folder in your project that has a subfolder named HelpPage:
Once your ASP.NET Web API functionality is complete you can browse to your site and add "help" on the end of the URL. For example: http://localhost:8080/help. The help path can be changed in the HelpPageAreaRegistration.cs file shown above if you'd like.
After going to the URL a help page that documents your Web API functionality will automatically appear and users can drill down into it to get additional details. A few examples of the default help page functionality are shown next:
The new ASP.NET Web API help page feature adds much needed functionality into ASP.NET MVC or ASP.NET Web Forms projects and makes your services much more discoverable. In addition to showing the default documentation, you can also tweak it to show custom samples. Additional details can be found at ASP.NET Web API Help Page Part 2: Providing custom samples on the Help Page.
Enjoy!
Dan Wahlin Microsoft MVP
.NET Developer Instructor
Interface Technical Training
You May Also Like
ASP.NET, Help Pages, HelpPage, JSON, MVC, MVCApplication, RESTful, Visual Studio 2012, Web API
Creating Dynamic DNS in Network Environments
0 603 1This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader teaches how to create Dynamic DNS zones in Network Environments. Video Transcription: Now that we’ve installed DNS, we’ve created our DNS zones, the next step is now, how do we produce those … Continue reading Creating Dynamic DNS in Network Environments
How to Build in a PSMethod to your PowerShell Code
0 71 0In this video, PowerShell instructor Jason Yoder shows how to add Methods (PSMethod) to your code using free software that’s added into the PSObject. For instructor-led PowerShell courses, see our course schedule. Microsoft Windows PowerShell Training Download the Building Methods PowerShell script</a> used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Building Methods ║ ╟──────────────────────────────────────────────────────────────────────────────╢ … Continue reading How to Build in a PSMethod to your PowerShell Code
How to use AWS CloudFormation templates to automate solutions inside Amazon AWS
0 380 0In the AWS Class here at Interface, we actually build fully automated solutions with AWS CloudFormations. Here’s an overview of using AWS templates using CloudFormation. CloudFormation is basically an “infrastructure-as-code tool” where you can go into a declarative document and define all the resources that you want and feed the document into the CloudFormation … Continue reading How to use AWS CloudFormation templates to automate solutions inside Amazon AWS