ASP.NET MVC 3, IDependencyResolver, and StructureMap
ASP.NET MVC 3 offers new facilities for easy dependency injection in various parts of the application that you might want to implement yourself. Brad Wilson discusses the new features in an extensive series of posts . In the Beta version and beyond, the way you do this is by creating a class that implements IDependencyResolver and serves as an adapter to the IoC container of your choice. I happen to like StructureMap as an IoC container so I thought I ‘d wire it up for use in ASP.NET MVC 3. IDependencyResolver isn’t exactly a complex interface to implement but being the properly lazy developer that I am I thought I’d look around on the web to see if anyone had already offered up an implementation for StructureMap. I found a few different blog posts that all had pretty much the same code (such as Brandon Satrom’s ) so I grabbed it and dropped it into my application. I then tried to have one of my controllers pulled from the container and .
Read the original here:
ASP.NET MVC 3, IDependencyResolver, and StructureMap


