2016-02-13 85 views
1

我有一個使用Owin上下文登錄用戶的MVC 4應用程序。記住我選擇或不選,用戶在5分鐘後被踢出系統。 Sessionstate被設置爲inProc,並且持續480分鐘。這裏是startup.cs文件:5分鐘後,MVC 4中的會話超時owin

public void ConfigureAuth(IAppBuilder app) 
    { 
// Enable the application to use a cookie to store information for the signed in user 
     // and to use a cookie to temporarily store information about a user logging in with a third party login provider 
     // Configure the sign in cookie 
     app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
      LoginPath = new PathString("/Account/Login"), 
      ExpireTimeSpan = TimeSpan.FromDays(14.0) 
     });    
     app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 

     AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Name; 

    } 

這裏是登入方法:

private void SignInAsync(string name, string role, bool isPersistent) 
    { 
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); 
     var claims = new List<Claim>(); 
     claims.Add(new Claim(ClaimTypes.Name, name)); 
     claims.Add(new Claim(ClaimTypes.Role, role)); 
     var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); 
     AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent}, identity); 
    } 

我想保持會話開放8小時,當用戶不檢查了rememberMe複選框,否則他們應該登錄14天。但是,我似乎無法弄清楚。任何幫助表示讚賞。

回答