我正在学习 asp.net MVC app 中的开放认证。通过Facebook登录,google工作正常但在部署时会话快速到期。主要是由于应用程序池回收。在我的本地系统工作正常。
我之前通过表单身份验证遇到了同样的问题,方法是将会话状态模式更改为“in proc”中的“state server”。如何为 open auth 做同样的事情?
我为会话超时设置了高值
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = new TimeSpan(1, 2, 30),
SlidingExpiration = true
});
1 回答
在许多情况下,共享 Web 服务器不允许长会话到期时间!你试过保存SQL Server 中的会话吗?