2

Is there a way to change Session Timeout on fly in ASP.NET MVC 5 globally without restarting application?

I know we can do

public void ConfigureAuth(IAppBuilder app)
        {            
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                ExpireTimeSpan = TimeSpan.FromMinutes(10),
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                CookieName = ".MyApp1_Authentication",
                SlidingExpiration = true
            });
}

But is there a way to do it in other places of the application? Thank you!

NoWar
  • 36,338
  • 80
  • 323
  • 498

1 Answers1

2

Close to a duplicate question but to answer this specifically, you can do this

  HttpContext.Current.Session.Timeout = 20;
dove
  • 20,469
  • 14
  • 82
  • 108