Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

advantage of IControllerActivator over DefaultControllerFactory.CreateController

Tags:

asp.net-mvc

What additional advantage does IControllerActivator.Create (new in MVC4) provides when controller can already be custom created (and resolved using DI) by overriding CreateController method of DefaultControllerFactory?

like image 706
helloworld Avatar asked Mar 07 '26 11:03

helloworld


1 Answers

The controller activation logic was pulled out of the default controller factory, and put in the controller activator; so it was done to make it a little more flexible and follow the singular responsibility pattern. Depending on what version of MVC you use, it now uses the controller activator to create the controller. The two work hand-in-hand to get the job done; therefore, you can customize either, and it will function similarly. I don't see there being an advantage one over the other.

See Brad Wilson's blog post about this.

like image 152
Brian Mains Avatar answered Mar 10 '26 06:03

Brian Mains