Introducing API Browser for ASP.NET MVC3
tl;dr - Automatically create a fully functional API page for your ASP.NET MVC project. https://github.com/gaurangsinha/API-Browser/
After working on a few ASP.NET MVC projects one of my main issues was testing our REST API manually, especially the POST methods. There are a few browser extensions like Poster for Firefox that help you do this, but it was still a tedious process.
API Browser was created as a tool that could be dropped into any project. It creates a page where the developer could test out his APIs without having to bother about spelling mistakes, forgetting parameters, etc etc.
API Page
Method with parameters and comments
Response [Success]
Response [Error]
The project can be found on github : https://github.com/gaurangsinha/API-Browser/
Getting Started
- Add APIBrowser reference to MVC project
- Add entry in
httpHandlersection inweb.config
- Add following line at the begining of
RegisterRoutesmethod inGlobal.asaxfile.The Global.asax file should now look like this:routes.IgnoreRoute("apibrowser.axd"); - Build & Run the project. Point the browser to
http://[localhost]:[port]/APIBrowser.axd
How does it work?
The APIBrowser utility will reflect all the assemblies associated with the project and filter out the types which inherit from System.Web.Mvc.Controller
The methods in these types will then be filtered by considering only the ones that have HttpPostAttribute or HttpGetAttribute as an attribute.
Consider you have the following controller file:
This file would be rendered to something like this:
What's next?
Right now APIBrowser considers that the default route is enabled i.e.
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Test", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);The plan is to figure out the alternative routes by inspecting the RouteCollection
Troubleshooting
If you are facing problems please check out the wiki. If the problem persists consider creating a ticket/issue. If you do plan to create a ticket/issue please provide as much information as you can to help me replicate and fix the problem.
*** Update ***
APIBrowser has now been updated to generate the virtual path for the controller & action.
Response time is also displayed with the results.




