From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Configuring dependency injection
From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations
Configuring dependency injection
- [Instructor] When configuring your apps in the Program.cs file, there are a couple of primary ways to include additional functionality, the injection of services and the inclusion of middleware. We'll talk about middleware in the next movie. Right now, I want to focus on how to inject services into your ASP.NET Core applications. First, when I talk about injecting services, I'm not talking about web services, but rather discrete pieces of functionality I want to make available in the app. These types of services are injected via the built-in dependency injection system. I'm not going to dive too deeply into this, but I do want to provide a quick overview of dependency injection in case this topic is new to you. Objects that depend on other objects can just create those objects as they need them. However, this makes it difficult to use a different implementation later, and the code is harder to unit test. When you use dependency injection, objects are passed dependencies, usually in…