AddTransient,AddScoped和AddSingleton服务的差异?我想要实现dependency injection在Asp.Net Core。因此,在将此代码添加到ConfigureServices方法之后,两种方式都有效。services.AddTransient和service.AddScoped方法有Asp.Net Core什么区别?public void ConfigureServices(IServiceCollection services){
// Add framework services.
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddScoped<IEmailSender, AuthMessageSender>();}
3 回答
- 3 回答
- 0 关注
- 1469 浏览
添加回答
举报
0/150
提交
取消