Introduction to Routing

The routing engine is responsible for getting the incoming request and routing that request to the appropriate controller based on the URL pattern. We can configure the routing engine so that it can choose the appropriate controller based on the relevant information. In other words, routing is a programmatic mapping that states which method of which controller is to be invoked based on some URL pattern.

By convention, ASP.NET MVC follows this pattern: Controller/Action/Id.

If the user types the URL http://yourwebsite.com/Hello/Greeting/1, the routing engine selects the Hello controller class and Greeting action method within the Hello controller, and passes the Id value as 1. XXXController is a naming convention and ...

Get ASP.NET Core 2 Fundamentals 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.