// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // 使用Session services.AddDistributedMemoryCache(); services.AddSession(options => { options.Cookie.Name = "j_session"; options.IdleTimeout = TimeSpan.FromSeconds(1200); //options.Cookie.Path = "/" + Settings.SYS_ADMIN_TAG; options.Cookie.HttpOnly = false; options.Cookie.IsEssential = true; }); // 启动异步IO services.Configure <IISServerOptions>(options => options.AllowSynchronousIO = true); services.Configure <KestrelServerOptions>(options => options.AllowSynchronousIO = true); // 使用MVC并添加Session支持 services.AddControllers().AddSessionStateTempDataProvider(); // GZIP services.Configure <GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Fastest); services.AddResponseCompression(options => { options.EnableForHttps = true; options.Providers.Add <GzipCompressionProvider>(); }); HttpContextNetCoreExtension.AddHttpContextAccessor(services); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // 使用Session services.AddDistributedMemoryCache(); services.AddSession(options => { options.Cookie.Name = "_cms_session"; options.IdleTimeout = TimeSpan.FromSeconds(1200); options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; }); // 启动异步IO services.Configure <IISServerOptions>(options => options.AllowSynchronousIO = true); services.Configure <KestrelServerOptions>(options => options.AllowSynchronousIO = true); // 使用MVC并添加Session支持 services.AddControllers().AddSessionStateTempDataProvider(); services.AddResponseCompression(); HttpContextNetCoreExtension.AddHttpContextAccessor(services); }