.net core 服务注册生命周期

在Asp.Net core中的IServiceCollection容器中注册服务的生命周期分以下3种:

1、Transient

通过AddTransient注册,会在IServiceCollection容器每次被请求时创建实例。

2、Scoped

通过AddScoped注册,会在每次客户端请求时创建实例

3、Singleton

通过AddSingleton注册,会在第一次被请求时创建实例,之后的每个请求都会使用这个实例

.net core 服务注册生命周期

上一篇:Debug a copy of the production database


下一篇:MyBatis中增删改操作