Asp.net core Flashcards

1
Q

What’s the difference between AddSingleton, AddScoped and Add Transient in ASP.NET Core

A

In ASP.NET Core Dependency Injection, AddSingleton, AddScoped, and AddTransient determine the lifetime of a service.
## AddSingleton
- When you want one instance per application lifetime.

2️⃣ AddScoped
- When you need one instance per HTTP request.
- Use for database repositories, unit-of-work patterns, business logic services.

3️⃣ AddTransient
- When you need a new instance every time it’s requested.
- Use for lightweight, stateless services like email senders, helper utilities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly