Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 表单身份验证-滑动过期_Asp.net_Asp.net Mvc_Forms Authentication - Fatal编程技术网

Asp.net 表单身份验证-滑动过期

Asp.net 表单身份验证-滑动过期,asp.net,asp.net-mvc,forms-authentication,Asp.net,Asp.net Mvc,Forms Authentication,我认为我的滑动过期没有发生,人们在几分钟后就一直注销。这是我的设置,slidingExpiration设置为“true”,timeout更新为“60”,而不是20,用于测试 <authentication mode="Forms"> <forms name="Lab.ASPXFORMSAUTH" loginUrl="~/Login" enableCrossAppRedirects="true" cookieless="AutoDetect" domain="lab.

我认为我的滑动过期没有发生,人们在几分钟后就一直注销。这是我的设置,slidingExpiration设置为“true”,timeout更新为“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>
看起来web.config和票证到期时间之间出现了一些中断。你知道我做错了什么吗?谢谢

更新#1:

测试开发站点,登录(FF和chrome),然后在5分钟后刷新页面,它让我保持登录状态。然后在14分钟后刷新页面,它将我重定向到登录页面


测试prod站点(2台服务器-负载平衡),遵循开发站点刷新间隔,让我登录

Scott Hanselman在这里详细介绍了它

你可能需要调查一下紧急情况

在asp.net论坛上获得了解决此问题的帮助

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);
        }