What is Dependency Injection in ASP .Net MVC? [Resolved]

Posted by Kumarkrishna184 under ASP.NET MVC on 12/26/2015 | Points: 10 | Views : 448 | Status : [Member] | Replies : 2
What is Dependency Injection in ASP .Net MVC and What is Unity IOC Container given by Microsoft?

Thanks and Regards,
Krishna Kumar



Responses

Posted by: Rajnilari2015 on: 12/26/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Kumarkrishna184 Sir,

What is Dependency Injection

Dependency Injection implies sending a dependency into a dependent object as opposed to the dependent object controlling life cycle of its dependencies. It uses a builder object to initialize objects and provide the required dependencies to the object which allows to inject a dependency from outside the class.It is a software design pattern that allow us to develop loosely coupled code

Advantages

- Helps to develop loosely coupled code
- Reduce tight coupling between software components
- Maintainable code
- Unit Testing

For specific to DI in MVC , please refer Sheo Sir's article at DNF :

http://www.dotnetfunda.com/articles/show/3178/simple-controller-dependency-injection-in-aspnet-mvc

What is Unity IOC Container

It is a lightweight DI container for building loosely coupled application that supports constructor injection, property injection, and method call injection.

Advantages

- Easy to create hierarchical object structures and dependencies.
- Support for runtime dependencies.
- Can be easily configured.
- Containers can be cached at the client end.

Please refer to this article as how to use Unity IOC Container in Asp.net MVC : http://www.dotnet-tricks.com/Tutorial/dependencyinjection/632V140413-Dependency-Injection-in-ASP.NET-MVC-4-using-Unity-IoC-Container.html


Hope it helps

--
Thanks & Regards,
RNA Team

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajnilari2015 on: 12/27/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
@Kumarkrishna184 Sir, Glad that it helped.

--
Thanks & Regards,
RNA Team

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response