-1

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?

U Nazir
  • 427
  • 1
  • 5
  • 11
  • Session timeout and the timeout for your authentication ticket are not tied together. Don't confuse them. – mason May 26 '22 at 16:42
  • There are a few things you should edit the question and be clear: 1) ASP.NET 4.x or ASP.NET Core? 2) Full IIS or IIS Express? IIS Express is not for production use if you don't know yet. 3) What's the authentication method? 4) What's the session mode? In-process or out-of-process? – Lex Li May 26 '22 at 19:59

1 Answers1

0

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))
    }
});
Mykhailo Nohas
  • 345
  • 1
  • 7