When developing a .NET backend service for your Mobile Azure Service, it is often useful to be able to try things out by sending HTTP requests and see what comes back – not to mention being able to debug what happens in the service. To facilitate this the .NET Backend comes with the ASP.NET Web API help page built in so that it is ready to go.

Note: The current bits allow full access to the help page and test client when running locally but for security reasons prevents them from being used when deployed in Azure. Soon you will also be able to access them in the cloud in a secure manner.

Prerequisites

We assume that you have created a Mobile Service with a .NET backend from the Azure portal, downloaded the TodoItem starter project, and opened it in Visual Studio 2012 or 2013. For details on how to do this, see Scott Guthrie’s blog.

The Help Page

Once you have downloaded the TodoItem starter project you can simply compile it and run it locally by hitting F5 in Visual Studio. This will bring up a page that looks like this (note that the address bar says “localhost”):

MobileServiceStartPage

Now, click on the try it out link and you will see something like this:

ApiDocs

You can continue diving into each action to see how it works. For example, if you click on the Todo Item GET action, you will see something like this indicating that the response is an array of todo items:

ApiDocsGet

Trying It Out with Test Client

If you hit the Try It Out link, you get to the test client allowing you to hit the API directly:

ApiDocsGetTest

By default the dialog has been filled in with what you need but you can modify the request by modifying the HTTP method, headers, or body. In this case, we just want a regular GET request so we just hit Send. The request is executed and you see the result like this:

ApiDocsGetTestResult

If you want to debug what happens, you can just set a breakpoint in your controller and when you execute the request from the test client, you will break into the controller (or anywhere else), for example:

ApiDocsGetTestDebug

Over the next weeks or so you will some improvements coming to the help page and test client including support /// style comments in your controllers and actions and use that as documentation so stay tuned!

Have fun!

Henrik