2016-02-13 48 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天。但是,我似乎无法弄清楚。任何帮助表示赞赏。

回答