In this blog I will answer the question: Is it possible to set the session timeout manually in ASP.NET?
Yes, we can set the session timeout manually in web.config.
In ASP.NET we can set the session timeout in the web.config file.The code below set the session timeout to 30 minutes.
- <system.web>
- <sessionState timeout="60"></sessionState>
- </system.web>
- <system.web>
- <sessionState mode="InProc" cookieless="false" timeout="30"/></system.web>
In C#
- protected void Page_Load(object sender, EventArgs e)
- {
- Session["MySession"] = "WELCOME";
- Session.Timeout = 1;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- Response.Redirect("default2.aspx");
- }

sunil chowdaryPosted Feb 4, 2019, 4:20 AM
How to set session time in seconds
Hemant YadavPosted Jun 15, 2018, 12:01 PM
How to maintain session timeout according to users role