Windows Server 2019上的本地II Express上的ASP.NET Web应用程序会话超时问题?

发布于 2025-02-01 12:50:42 字数 243 浏览 3 评论 0原文

我有一个ASP.NET 4.X MVC应用程序,该应用程序托管在我们在IIS Express上的本地Windows 2019服务器上。

在web.config文件中,会话超时已配置为8小时(进程中的会话模式)。这意味着,如果用户登录,则他的shoud登录了8个小时,但这不会发生。在本地网络上使用此应用程序的最终用户,他们在几分钟后就会注销,并且必须一次又一次登录。

我什至在IIS设置上配置了这次,但仍然没有成功。

我缺少什么?

I have an ASP.NET 4.x MVC application which is hosted on our local Windows 2019 Server on IIS Express.

In web.config file session timeout is configured for 8 hours (Session mode in process). Which means if a user logins he shoud remain logged in for 8 hours, but this is not happening. End users who are using this application on local network, they get logout just after few minutes and they have to log in again and again.

I have even configured this time on IIS settings but still no success.

Anything I am missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风挽心 2025-02-08 12:50:42

我相信您可能还需要通过为cookiuthentication提供商设置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))
    }
});

I believe you might need also to modify Startup.cs file by setting validateInterval for CookieAuthentication Provider.
Below you can find example how it has been handled in my application where time of automatic logging out was increased to 60 min:

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))
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文