表单身份验证 - 滑动过期
问题描述:
我认为我的滑动过期没有发生,并且人们在几分钟后不断注销。这里是我的设置,slidingExpiration被设置为“true”并且超时我更新为“60”而不是20,用于测试目的。表单身份验证 - 滑动过期
<authentication mode="Forms">
<forms name="Lab.ASPXFORMSAUTH" loginUrl="~/Login" enableCrossAppRedirects="true" cookieless="AutoDetect" domain="lab.org" slidingExpiration="true" protection="All" path="/" timeout="60" />
</authentication>
这里是登录码。如果记住我被选中,那么机票到期时间将从新世纪开始是一年,从现在起将是20分钟。
private static void LoginUser(User user, bool isRememberMe)
{
//Forms Authentication
var expiryDateTime = isRememberMe ? DateTime.Now.AddYears(1) : DateTime.Now.AddMinutes(20);
var ticket = new FormsAuthenticationTicket(
1, // Ticket version
user.UserId, // Username associated with ticket
DateTime.Now, // Date/time issued
expiryDateTime, // Date/time to expire DateTime.Now.AddYears(1)
isRememberMe, // "true" for a persistent user cookie
JsonConvert.SerializeObject(user.Roles), // User-data, in this case the roles
FormsAuthentication.FormsCookiePath); // Path cookie valid for
// Encrypt the cookie using the machine key for secure transport
var hash = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(
FormsAuthentication.FormsCookieName, // Name of auth cookie
hash); // Hashed ticket
// Set the cookie's expiration time to the tickets expiration time
if (ticket.IsPersistent)
{
cookie.Expires = ticket.Expiration;
}
// Add the cookie to the list for outgoing response
HttpContext.Current.Response.Cookies.Add(cookie);
}
看起来我在web.config和票证到期时间之间会有一些断开。你看到我在这里做错了吗?由于
更新#1:
测试的开发站点,登录(FF和铬),然后刷新页面,5分钟后,它让我登陆,然后刷新14mins后的页面,并将其重定向我。登录页面。
测试督促现场(2个服务器 - 负载平衡),然后在开发站点刷新间隔,让我登录
答
Scott Hanselman在这里详述它。
http://www.hanselman.com/blog/WeirdTimeoutsWithCustomASPNETFormsAuthentication.aspx
你可能需要考虑iisidle超时
https://technet.microsoft.com/en-us/library/cc771956%28v=ws.10%29.aspx
得到了帮助,在asp.net论坛来解决该问题。