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

纵饮孤独 提交于 2019-12-11 04:24:33

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8077104/if-you-are-starting-a-new-mvc3-project-which-adaption-will-you-choose-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!