Skip to content

In .NET Core, you can register dependencies using three different methods AddSingleton, AddTransient, and AddScoped. This blog explains each of these methods.

Notifications You must be signed in to change notification settings

geeksarray/net-core-dependency-injection-object-lifetime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

.NET Core Dependency Injection Object Lifetime

In .NET Core, you can register dependencies using three different methods AddSingleton, AddTransient, and AddScoped. This blog explains each of these methods.

Objects injected using Dependency Injection have a specific lifetime. Object's lifetime depends on how you register dependency. To understand how each method is different from than others we will create a console application, and service and inject this service to application middleware.

  1. AddSingleton

  2. AddTransient

    .NET Core Dependency Injection Transient Instance

  3. AddScoped

    .NET Core Dependency Injection Scoped Instance

For more information please visit https://geeksarray.com/blog/net-core-dependency-injection-object-lifetime

About

In .NET Core, you can register dependencies using three different methods AddSingleton, AddTransient, and AddScoped. This blog explains each of these methods.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages