Creating a Custom Controller Factory

Quick notes about replacing the current controller factory in ASP.NET MVC

How to Create the Custom Controller Factory

  1. Create a class that inherits from DefaultControllerFactory (see this)
  2. 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)

  1. 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.
  2. You can inject the dependencies (like repositories) into the constructor automatically

Other interesting tidbits.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: