Asp.net mvc 4 dependency resolver

Aslam Jiffry picture Aslam Jiffry · Nov 20, 2013 · Viewed 16.1k times · Source

I am new to ASP.NET MVC 4. I have used a custom dependency resolver in my ASP.NET MVC 4 project in order to use Dependency injection framework.

What is the role of dependency resolver in ASP.NET MVC 4 ?

Answer

evhen14 picture evhen14 · Nov 20, 2013

It allows you to abstract away from Dependency Injection implementation. Later if you decide to switch from Unity to Windsor, you can do it much easier without having to re-write lots of code

It means that you can resolve your instances using this code

DependencyResolver.Current.GetService<IMyController>();