30

如何实现自动注销计时器。

所以基本上如果用户在 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 身份验证。因此,如果我能做到,我不知道这意味着什么。

4

1 回答 1

66

它在文件中的一个属性App_Start\Startup.Auth.cs

  app.UseCookieAuthentication(new CookieAuthenticationOptions
  {
      ExpireTimeSpan = TimeSpan.FromMinutes(5),
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
      LoginPath = new PathString("/Account/Login")
   });
于 2014-02-06T19:50:54.977 回答