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:
- When a new request arrives, the routing middleware parses the incoming URL.
- A matching route is searched in the RouteCollection.
- If a matching route is found, control is passed to the RouteHandler.
- If a matching route is not found, the next middleware is invoked.