我正在学习asp.net核心(使用2.1版);我正在使用会话存储一些用户信息,但是每次我停止应用程序并再次运行时,会话信息都会被完全清除(仍然有会话cookie)浏览器)我在启动时就有这些:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.Strict;
});
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["DefaultConnection"]));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSession(config =>
{
config.Cookie.Name = "Cart";
config.Cookie.MaxAge = TimeSpan.FromDays(365);
config.IdleTimeout = TimeSpan.FromDays(365);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSession();
app.UseMvc();
}
有人可以告诉我发生了什么事吗?