【问题标题】:My website is logged out everytime i come back每次我回来时我的网站都会注销
【发布时间】:2019-06-20 16:57:54
【问题描述】:

我正在开发一个 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 .net cookies asp.net-core


【解决方案1】:

请试试这个

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 - 更多详情。

【讨论】:

    猜你喜欢
    • 2012-09-06
    • 1970-01-01
    • 2021-11-03
    • 2014-10-25
    • 1970-01-01
    • 2022-12-19
    • 1970-01-01
    • 1970-01-01
    • 2012-07-24
    相关资源
    最近更新 更多