ASP.NET MVC Controller Factory life cycle
The DefaultControllerFactory contains three different methods:
GetControllerInstanceCreateControllerGetControllerType
When is each method executed in the request lifetime? I've seen custom controller factories where one of these methods is overridden and implemented bu开发者_高级运维t I can't seem to find details on the execution path of each one.
CreateController gets called.
It first calls GetControllerType to figure out type of the controller, then passes this type to GetControllerInstance.
Because it is easier (and often enough) to (only) override GetControllerInstance (so that the logic behind selecting the type remains the same), you'd often see this happening.
Update for MVC3, the methods are called in this order.
GetControllerType gets called first and gets called twice.
GetControllerTypeGetControllerSessionBehaviorCreateControllerGetControllerTypeCreateControllerInstanceReleaseController
加载中,请稍侯......
精彩评论