Question

I am migrating to ASP.NET MVC 3.

Now I have some ways of resolve controller with IoC.

My controller need a contructor injection parameter for repositories.

Setting DependencyResolver.SetResolver works. But I don´t know if this is correct way or I need to Register a IControllerActivator at my container too.

Was it helpful?

Solution

What you need is a ControllerFactory.Most IOC containers have an existing implementation. If you need a custom one, check this article:

http://develoq.net/blog/?p=144

Update

It's the correct way. DependencyResolver is generic for everything, and you need to register the IControllerActivator in it.

http://bradwilson.typepad.com/blog/2010/10/service-location-pt10-controller-activator.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top