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?