Hi ,
How to set session time out 3 hour in asp.net.
Regards,
Pratik
Hi ,
How to set session time out 3 hour in asp.net.
Regards,
Pratik
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Oct 31, 2023, 4:32 AM EDT
Hello PRatik,
You can achieve in two way,
protected void Application_Start(object sender, EventArgs e) { // Set the session timeout to 3 hours (180 minutes) System.Web.SessionState.SessionStateSection sessionState = (System.Web.SessionState.SessionStateSection)System.Configuration.ConfigurationManager.GetSection("system.web/sessionState"); sessionState.Timeout = new TimeSpan(0, 180, 0); }Vishal JoshiRank #377 · 6.7K reputationPosted Oct 31, 2023, 6:00 AM EDT
Hello
In asp.net core, you can use ConfigureServices to set session time out. please checkout the below sample code for the same.
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); //Set Session Timeout. Default is 20 minutes. services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(180); }); }Thanks
Vishal