Quick notes about replacing the current controller factory in ASP.NET MVC
How to Create the Custom Controller Factory
- Create a class that inherits from DefaultControllerFactory (see this)
- Set the controller factory in application start (see this)
That’s should be about it 🙂
Why would you implement a custom controller factory? (Thoughts for me relating specifically to IoC)
- You can configure which type of controller you want, so you can configure the IoC container to load a new class that is in a dll that you chuck in the bin directory.
- You can inject the dependencies (like repositories) into the constructor automatically
Other interesting tidbits.
- OdeToCode – MVC 2 Areas and Containers