-
Book Overview & Buying
-
Table Of Contents
ASP.NET Core 5 for Beginners
By :
There are a few options when it comes to implementing DI within your ASP.NET Core applications, and these include the following approaches:
Let's talk about each type in detail in the coming sections.
We've seen how we can implement constructor injection earlier in our music list example. But to recap, this approach basically allows you to inject lower-level dependent components into your class by passing them into the constructor class as arguments.
This approach is the most commonly used when building ASP.NET Core applications. In fact, when you create an ASP.NET Core MVC project from the default template, you will see that DI is, by default, integrated. You can verify this yourself by looking into the HomeController class and you should see the ILogger interface being injected into the class constructor...