Demystified: Routing in ASP.NET Core

Learn how routing in ASP.NET Core works to map incoming requests to respective controller actions

Routing maps incoming requests to the respective route handlers and generates outgoing URLs. ASP.NET Core is an open source, cross-platform, lean, and modular framework for building high-performance web applications.

Routing in ASP.NET Core is managed by the routing middleware in the Microsoft.AspNetCore.Routing namespace. The middleware handles requests and responses and inspects, routes, and even modifies the request and response messages that flow through the pipeline.

In essence, routing in ASP.NET Core maps the incoming URLs to the respective controller actions and then generates the corresponding outgoing URLs.

Here's how routing in ASP.NET Core works:

  1. When a new request arrives, the routing middleware parses the incoming URL.
  2. A matching route is searched in the RouteCollection.
  3. If a matching route is found, control is passed to the RouteHandler.
  4. If a matching route is not found, the next middleware is invoked.

To continue reading this article register now

How to choose a low-code development platform