问题描述
我是asp.net核心的新手.我试图在一段时间不活动后实施用户注销.有人可以建议指南/教程,也可以解释如何使用asp.net core 2.0和MySql而不是Entity Framework来实现此功能.
I am new to asp.net core. I am trying to implement User Logout after being inactive for a period of time. Can someone suggest guide/tutorial or explain how to implement this using asp.net core 2.0 and MySql instead of Entity Framework.
推荐答案
在使用AddIdentity
或AddDefaultIdentity
在服务中配置了您的身份之后,您可以配置Cookie ExpireTimeSpan
After configuring your identity in the services using AddIdentity
or AddDefaultIdentity
you can configure your cookie ExpireTimeSpan
您可以阅读链接文章中的 Cookie设置 块.
You could read Cookie Settings block in the linked article.
services.ConfigureApplicationCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
options.LoginPath = "/Identity/Account/Login";
options.SlidingExpiration = true;
});
ExpireTimeSpan
是TimeSpan
,之后cookie将过期. SlidingExpiration
将指示处理程序一个具有新到期时间的新cookie.
ExpireTimeSpan
is the TimeSpan
after which the cookie will expire. SlidingExpiration
will instruct the handler a new cookie with new expiration time.
这里的文档:
这篇关于在asp.net core中不活动后注销用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!