Understanding Service Routing

As you saw with the method Get(id) in the CustomerController class, service methods in ASP.NET Web API are accessed via a URL routing convention. This convention works in a similar way to the routing in ASP.NET MVC. The biggest difference is that Web API leverages the HTTP verb to select the appropriate action in your controller.

A request is sent to your website, parsed for the HTTP verb (GET, POST, PUT, DELETE), and processed through a routing engine. The routing engine uses conventions to find your controller and map the request based on verb and parameters to the appropriate action method. Recall that we set the route for the CustomerController class at the top of the class using the attribute [Route("api/[controller]")] ...

Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.