更新时间:2023-12-02 13:16:22
在使用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.
这里的文档:
摘要: 将SlidingExpiration设置为true,以指示处理程序重新发出新的 每次处理请求的Cookie都具有新的到期时间 超过到期窗口的一半.
Summary: The SlidingExpiration is set to true to instruct the handler to re-issue a new cookie with a new expiration time any time it processes a request which is more than halfway through the expiration window.