2015-03-13 78 views
0

我認爲我的滑動過期沒有發生,並且人們在幾分鐘後不斷註銷。這裏是我的設置,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個服務器 - 負載平衡),然後在開發站點刷新間隔,讓我登錄

回答