public void ConfigureServices(IServiceCollection services) { services.AddLogging(logging => { logging.AddConfiguration(Configuration.GetSection("Logging")); logging.AddDebug(); }); //注册业务服务 ServiceFactory.Initialize(services, Configuration); //用户认证注册 AuthenticationFactory.Initialize(services); services.AddMvc(options => { //add filters options.Filters.Add(typeof(ErrorAttribute)); }); services.AddMemoryCache(); services.AddScoped <IMemCache, MemCache>(); //services.AddDistributedMemoryCache(); 区别 services.AddSession(); CoreProviderContext.ServiceCollection = services; }