Asp.net mvc 4 dependency resolver
16,087
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>();
Related videos on Youtube
Comments
-
Aslam Jiffry over 1 year
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 ?
-
Aslam Jiffry over 10 yearsI have used using global.asax.cs file to register the custom dependency resolver. But in global.asax.cs file I didn't find any registering about default dependency resolver.
-
-
Aslam Jiffry over 10 yearslets say what if we didn't use a dependency injection framework. how default dependency resolver going to work.
-
evhen14 over 10 yearsIt should not work. For example, for controllers it will use Default Controller Factory that creates controllers using their default constructors
-
user1176058 almost 10 years@evhen14, I think DefaultControllerfactory uses DependencyResolver to create controller instances.
-
Hooman Bahreini over 5 yearsThis answer explains the standard way of using ninject, it has nothing to do with the question.