AddTransient, AddScoped and AddSingleton Services Differences
I want to implement dependency injection (DI) in ASP.NET Core. So after adding this code to ConfigureServices
method, both ways work.
What is the difference between the services.AddTransient
and service.AddScoped
methods in ASP.NET Core?
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddScoped<IEmailSender, AuthMessageSender>();
}