Home >Backend Development >C#.Net Tutorial >What is routing in C# ASP.NET Core?
Routes are used to map requests to route handlers.
Routes are configured when the application starts and can be accessed from The URL that will be used for request processing.
Routing uses routing (implementation of IRouter)
Routes are connected to the middleware pipeline through the RouterMiddleware class. ASP.NET MVC adds routes to the middleware pipeline as part of its configuration
Incoming requests go into the RouterMiddleware that calls the RouteAsync method
IRouter instance is set by RouteContext handler for a non-null RequestDelegate.
If the handler has a route set, it will be called to handle the request and will go no further Routing will be processed.
If all routes are executed and no handler for the request is found, the middleware will call next and the next middleware in the request pipeline are called.
URL generation follows a similar iterative process, but starts with the user or frame Code that calls the route collection's GetVirtualPath method.
Each route then calls its GetVirtualPath method in sequence until Returns non-null VirtualPathData
Routing provides the Route class as the standard implementation of IRouter. Routes use route template syntax to define what will be used with The URL path when calling RouteAsync.
When GetVirtualPath is , Route will use the same route template to generate the URL transfer.
routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
The framework provides a set of extension methods for creating routes, such as -
MapRoute MapGet MapPost MapPut MapRoute MapVerb
The above is the detailed content of What is routing in C# ASP.NET Core?. For more information, please follow other related articles on the PHP Chinese website!