1, MVC how to instantiate the controller?

We know that MVC request comes in, and then routed match, then find the controller and Action, will eventually call the Action method, but we think the controller is a common category, Action is an ordinary instance method, in order to call the Action must first instantiate control device, then the MVC how to instantiate the controller of it?

1, MVC request will first come into UrlRoutingHandler in the ProcessRequest

 2, and then proceeds to MVCHandler in the ProcessRequest

3, MVCHandler where ProcessRequestInit, which in this example of the controller

1, string requiredString = this.RequestContext.RouteData.GetRequiredString ( "controller"); matching results generated after the set route RouteData, to give requiredstring string, requiredString is a complete type name

2, ControllerBuilder.GetControllerFactory (); DefaultControllerFactory get the default control plant, and then to create a method DefaultControllerFactory CreateController Controller instance by using Reflected

Guess you like

Origin www.cnblogs.com/menglin2010/p/11425705.html