views:

180

answers:

2

What are Benefits of using ASP.NET MVC Controller Injection (IoC) ?

+1  A: 

Pretty much the same general advantages one gets from dependency injection applied to the case of MVC controllers.

Wyatt Barnett
+3  A: 

I did a video on this if it helps: http://www.asp.net/learn/mvc-videos/video-366.aspx

The idea with IoC is that you have no dependencies declared in your controller - only interfaces. This allows for high re-use.

Think in terms of membership - you might have an AccountController you really like and want to carry around with you. Normally you might use Linq to Sql, but on this new project you want to use SubSonic or NHib. If you use IoC there is no code you need to change in your AccountController - you only need to implement your new interface.

Rob Conery