C# .NET Interview Questions and Answers

What is the difference between AddSingleton, AddScoped, and AddTransient?

  • AddSingleton: Creates a single instance for the entire application lifecycle.

  • AddScoped: Creates a new instance for each HTTP request.

  • AddTransientCreates a new instance every time it is requested.

More details in dependency injection lifecycle in asp.net core
An unhandled error has occurred. Reload 🗙