ASP.NET Core in .NET 6: Dependency Injection

ASP.NET Core in .NET 6: Dependency Injection

47mIntermediate2022-04-29

Authors

David Grace

David Grace

Senior .NET Web Developer

Course details

If you’re a .NET developer or looking to enter the field, it’s essential to have a working understanding of dependency injection, a software development design pattern that allows for having objects that are not dependent on each other. In this course, .NET C# programmer David Grace provides an introduction to dependency injection, from configuration to implementation. He also talks through the advantages of DI and why you should use it. David shows how to implement dependency injection into a real-life example using an ASP.NET Core app, and details the use methods within it. He also looks at the common errors when using dependency injection and how to resolve them.

Skills covered

ASP.NET CoreBack-End Web DevelopmentProgramming FoundationsFull-Stack Web DevelopmentFront-End Web DevelopmentWeb DevelopmentMicrosoftSoftware DevelopmentDeep Dive (X:Y)

Concepts

Introduction

  • Dependency injection overview
  • What you should know
  • Setting up your environment

What Is Dependency Injection

  • What is dependency injection
  • Service lifetimes

Configuring Dependency Injection in ASP.NET Core

  • Setting up the services
  • How to configure dependency injection
  • Other dependency injection configuration methods

Using Dependency Injection in ASP.NET Core

  • How to inject services into a controller
  • Inject services in other components of a web application
  • How to set up a hosted service
  • Disposing of a service
  • Challenge - Set up an application using dependency injection
  • Solution - Set up an application using dependency injection

Common Errors

  • Forgetting to add a service
  • Injecting services with different service lifetimes
  • Circular dependency
  • Ambiguous constructors

Conclusion

  • Continue your ASP.NET Core journey
40,000 Toman