Data Access has been discontinued. Please refer to this page for more information.

Calling the Web API from the Browser

You can use any HTTP client to invoke your web API. In fact, you can invoke it directly from a web browser. In Visual Studio, start your application in debugging mode. Visual Studio will automatically open a web browser window with URL that points to http://localhost<portnumber>. The port number is automatically chosen by the development server. The public methods of the controller are called action methods. When the Web API framework receives a request, it routes the request to an action. To determine which action to invoke, the framework uses a routing table.

To invoke the custom GetCarsByMake method, browse to http://localhost:<portnumber>/api/cars?Make=Opel. Replace the <portnumber> with the actual port number. The exact result depends on the web browser you are using. The reason is that the different browsers send different Accept headers.

In this task, you saw how to call Web API directly in the browser. However, most Web APIs are meant to be consumed programmatically by client applications. In the next task, you will see how to do this by using JavaScript, jQuery and Kendo UI Grid.