首页 > 解决方案 > 每次我回来时我的网站都会注销

问题描述

我正在开发一个 asp.net core 2 web 应用程序。出于某种原因,当我有一段时间(即 1 小时)没有进入时,它会被注销

这是我的 web.config:

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\Ojete.UI.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

由于我不知道这是如何发生的,我不知道我应该发布代码的另一部分。对于那个很抱歉!

标签: asp.net.netcookiesasp.net-core

解决方案


请试试这个

services.AddAuthentication()
.Services.ConfigureApplicationCookie(options =>
{
    options.SlidingExpiration = true;
    options.ExpireTimeSpan = TimeSpan.FromMinutes(30); // here you can change timeout
});

https://github.com/aspnet/Identity/issues/1389 - 更多细节。


推荐阅读