Search code examples
asp.net-mvc-3castle-windsorcontroller-factory

If you are starting a new MVC3 project which adaption will you choose DependencyResolver or ControllerFactory with Castle Windsor?


I am new to the ioc containers and confused how to integrate a container to mvc3...

There is a sample that uses ControllerFactory... https://github.com/kkozmic/ToBeSeen/blob/master/src/ToBeSeen/Plumbing/WindsorControllerFactory.cs

There is a blog post that says "The MVC 3.0 IDependencyResolver interface is broken. Don’t use it with Windsor." http://mikehadlow.blogspot.com/2011/02/mvc-30-idependencyresolver-interface-is.html

and from this link I think I also need to implement IControllerActivator... Castle Windsor Dependency Resolver for MVC 3

In pluralsight's mvc3 dependency resolution videos scot allen says using activators is necessary if your ioc container is not enough for it... this also makes me think about using windsor with DependencyResolver.


Solution

  • I'm using ControllerFactory since a while with no problem at all. There's a very usefull tutorial on windsor wiki

    In case you need your action been resolved by an IoC I suggest you http://weblogs.asp.net/psteele/archive/2009/11/04/using-windsor-to-inject-dependencies-into-asp-net-mvc-actionfilters.aspx

    Due to missing release operation, IDependencyResolver is not enough: stay away from it.