Creating a custom ControllerFactory class requires that you implement System.Web.Mvc.IControllerFactory.
This method has three methods:
The CreateController method handles the actual control creation, so if you were creating a customized constructor, this is where your code would participate.
The ReleaseController method cleans the controller up. In some cases, you might be freeing up your IoC container; in other cases, you might be logging out a service connection.
The GetControllerSessionBehavior method enables you to define and control how your controller works with session.
After you create your own ControllerFactory class, you need to register it for use. You can add the following code to the Global.asax Application_Start method:
ControllerBuilder.Current.SetControllerFactory(typeof(MyCustomControllerFactory());
This method has three methods:
- CreateController
- ReleaseController
- GetControllerSessionBehavior.
The CreateController method handles the actual control creation, so if you were creating a customized constructor, this is where your code would participate.
The ReleaseController method cleans the controller up. In some cases, you might be freeing up your IoC container; in other cases, you might be logging out a service connection.
The GetControllerSessionBehavior method enables you to define and control how your controller works with session.
After you create your own ControllerFactory class, you need to register it for use. You can add the following code to the Global.asax Application_Start method:
ControllerBuilder.Current.SetControllerFactory(typeof(MyCustomControllerFactory());
No comments:
Post a Comment