Yesterday, Phil Haack posted an article about using ASP.NET MVC along with an IoC container, namely StructureMap. Last month, Fredrik Normen wrote a similar article, but used Spring.NET instead. I must say, I was pretty impressed by how rediculously easy it is to customize the controller factory to play nice with whichever IoC container you want.
My first reaction to reading those two posts was “Ok, that’s great, now where is the Codeplex project to aggregate these controller factories into one common place?”. We all know that applying the DRY principle, we’d hate to have to continue replicating such trivial code over and over again just to integrate simple DI into our MVC app. Well I should have known that Jeffrey Palermo was already spearheading such a project, called MVC Contrib.
If you look at the first item in the list of project contents, you’ll see:
“IoC container controller factories for the popular containers: StructureMap, Windsor, Spring.Net, etc (i.e. whoever wants to contribute others)”
Perfecto! You’ll notice the project hasn’t actually started yet (considering the CTP for ASP.NET MVC hasn’t even been released, can you blame em’?), but it promises to offer some great additional functionality in addition to the out-of-the-box goodness.