asp.net-mvc MVC 5 身份自动注销
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21604019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MVC 5 Identity Automatic Logout
提问by Zapnologica
How do I implement an Automatic Logout Timer.
如何实现自动注销计时器。
So basically if the user is inactive for x minutes their session is ended?
所以基本上如果用户在 x 分钟内处于非活动状态,他们的会话就结束了吗?
I have tried:
我试过了:
<system.web>
<sessionState timeout="1"/>
</system.web>
But it doesn't seem to work.
但它似乎不起作用。
Here is code that is in my startup:
这是我的启动中的代码:
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")
});
}
Which says that I am using cookie Authentication. So i dono what that entails if I can do it or not.
这说明我正在使用 cookie 身份验证。所以我不知道我能不能做到。
回答by Hao Kung
Its a property in the App_Start\Startup.Auth.csfile:
它在App_Start\Startup.Auth.cs文件中的一个属性:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromMinutes(5),
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});

