Search code examples
c#.netasp.net-mvc-4dependency-resolver

Asp.net mvc 4 dependency resolver


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 ?


Solution

  • 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>();