O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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]")] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required