Asp.net-Mvc

MVC 5 身份自動註銷

  • February 6, 2014

如何實現自動註銷計時器。

所以基本上如果使用者在 x 分鐘內不活動,他們的會話就結束了?

我努力了:

<system.web> 
  <sessionState timeout="1"/>
</system.web>

但這似乎不起作用。

這是我啟動時的程式碼:

public void ConfigureAuth(IAppBuilder app)
{
 // Enable the application to use a cookie to store information for the signed in user
 app.UseCookieAuthentication(new CookieAuthenticationOptions
 {
     AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
     LoginPath = new PathString("/Account/Login")
  });
}

這說明我正在使用 cookie 身份驗證。因此,如果我能做到,我不知道這意味著什麼。

它在文件中的一個屬性App_Start\Startup.Auth.cs

 app.UseCookieAuthentication(new CookieAuthenticationOptions
 {
     ExpireTimeSpan = TimeSpan.FromMinutes(5),
     AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
     LoginPath = new PathString("/Account/Login")
  });

引用自:https://stackoverflow.com/questions/21604019