Where is MvcRouteHandler registered?

I am trying to understand ASP.Net MVC at a lower level. In particular, I am trying to understand how the MVC runtime starts. For my initial digging into the stack / decompilation of the call, it seems like it is started by MvcRouteHandler, which then creates the MvcHandler. However, I cannot find where MvcRouteHandler is registered. How is this RouteHandler added to the ASP.Net pipeline?

Update
Upon further verification, I traced the MvcRouteHandler construct to the MvcRouteHandler class, which will contain the extensions for the RouteCollection class. A specific method containing a constructor has the following definition:

 public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces) 

I believe the key is found in this line of code:

 Route route = new Route(url, new MvcRouteHandler()); 

So for me this is assigned by MvcRouteHandler. The general chain of events is as follows:

It all starts with Global.asax.cs

 Application_Start() RouteConfig.RegisterRoutes RouteCollectionExtensions.MapRoute(this RouteCollection routes, string name, string url, object defaults) RouteCollectionExtensions.MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints) RouteCollectionExtensions.MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces) 

From here it’s just a matter of matching the route, which then leads to the use of the MvcRouteHandler, which calls the MvcHandler and fires the whole chain of events. Therefore, my initial assumption that MvcRouteHandler was registered in the config was incorrect. Instead, it is configured through code starting with the Application_Start event in the global.asax.cs file.

Is it correct?

+4
source share
1 answer

The request goes through the ASP.net pipeline, and then gets into the UrlRoutingModule HTTP module.

Additional Information: How does ASP.NET MVC work?

Change The routing module is installed on your web.config computer, which inherits your web.config site. You can find it on %systemroot%\Microsoft.NET\Framework\$versionNumber$\CONFIG\Web.config

enter image description here

+5
source

Source: https://habr.com/ru/post/1441936/


All Articles