-
Book Overview & Buying
-
Table Of Contents
Modern Full-Stack Web Development with ASP.NET Core
By :
Routing in ASP.NET Core is achieved through a middleware component that analyzes the incoming URL and decides which controller and action method to execute. Thus, understanding and configuring routing correctly is essential for building effective MVC applications. When you start a new MVC project in ASP.NET Core, the routing configuration is set up in the Program.cs file, typically in the Configure method.
In the default configuration, ASP.NET Core uses a routing approach known as convention-based routing. This setup defines routes based on patterns established in the startup configuration. A typical pattern might look like /controller/action/id, where each segment of the URL corresponds to a specific aspect of the routing logic – the controller name, the action method, and an optional parameter, often used as an identifier.
For example, consider the convention-based routing setup defined in Program.cs that is seen in the following...