I am starting a new project using MVC4 and would like to use dependency injection. I’ve not used it in the past but now seems like a good time to use it.
Can anyone tell me which DI tools now support MVC4 and which now offer the most easy set-up. My needs a fairly simple as the project is small. Most important for me is a system that is easy to learn and configure.
I dont know MVC 4 (i just haven’t had a chance to play with it yet) but i would recommend Ninject as a DI container. You can probably just install the Ninject MVC3 project (from nuget) in your solution and it may well just work with MVC4
If not use:
which was blogged about here http://blogs.microsoft.co.il/blogs/gilf/archive/2010/10/17/dependency-injection-in-mvc-3-was-made-easier.aspx
the blog post applies to unity but its pretty much the same for Ninject, implement a Dependancy Resolver to wrap ninject and put it into the global.ascx file