我注意到现在超时的会话大约是20-30分钟。
这是我之前使用的代码,但它不适用于RC1。
app.UseInMemorySession(configure: s => s.IdleTimeout = TimeSpan.FromDays(30));
即使IIS网站进程重新启动,我也想保留会话状态......所以我猜UseInMemorySession不是最佳选择。
答案 0 :(得分:1)
在您的Startup.cs
中应该有ConfigureServices
方法,您可以在其中增加IdleTimeout
:
public void ConfigureServices(IServiceCollection services)
{
// Code omitted
services.AddSession(options => {
options.IdleTimeout = TimeSpan.FromMinutes(50);
options.CookieName = ".FooApplication";
});
}
你可以使用Redis或SqlServerCaching,我从来没有这样做过,因为我避免使用会话来支持OAuth和在客户端的令牌中序列化的声明。
本文看起来可能是您需要的: