簡體   English   中英

ASP.NET web 應用程序 session 本地 IIS Express 上的超時問題 Windows Server 2019?

[英]ASP.NET web application session timeout issue on local IIS Express on Windows Server 2019?

我有一個 ASP.NET 4.x MVC 應用程序,它托管在我們本地 Windows 2019 服務器上的 IIS Express 上。

在 web.config 文件中,session 超時配置為 8 小時(正在處理會話模式)。 這意味着如果用戶登錄,他應該保持登錄狀態 8 小時,但這並沒有發生。 在 local.network 上使用此應用程序的最終用戶會在幾分鍾后注銷,他們必須一次又一次地登錄。

這次我什至在 IIS 設置上進行了配置,但仍然沒有成功。

我有什么想念的嗎?

我相信您可能還需要通過為 CookieAuthentication Provider 設置 validateInterval 來修改 Startup.cs 文件。 您可以在下面找到示例,它是如何在我的應用程序中處理的,其中自動注銷的時間增加到 60 分鍾:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    SlidingExpiration = true,
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider
    {
        // Enables the application to validate the security stamp when the user logs in.
        // This is a security feature that is used when you change a password or add an external login to your account.  
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
            validateInterval: TimeSpan.FromMinutes(60),
            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM