Set the default Session TimeOut for your ASP.NET application

You can set the default time out period of the asp.net session state for your web application from the web config file.

By default in asp.net websites session has the timeout period of the 20 mins after that session will gets expire. You can change this timeout for your application(through the global.ascx and web config file) or for the entire applications running on your web server(through the IIS Manager).

See below to set session timeout in web.config

We can set session timeout in the web.config file like as:

<configuration>
<system.web>
 <sessionState mode="InProc" timeout="60">
 </sessionState>
 </system.web>
</configuration>

–Or–
Use the Session_Start event of the Global.ascx file:

void Session_Start(object sender, EventArgs e)
{
Session.Timeout = 60;
}

Using IIS7 Manager

You can set default session timeout for the all the running application on the server. Follow these steps:

(1) Open IIS start–>run type–>inetmgr and press enter.
–or–
Goto ‘All Control panel items’, Click on the ‘Administrative Tools’ and then click on the ‘IIS Manager’.

(2) Right Click on “Default Web Site” and click on the ‘Properties’.

(3) Select Asp.Net tab, click on “Edit Configuration” Button.

(4) Select “State Management tab” in new popup window. Change the Time out property field in the ‘cookie settings’ section.

Session time out setting in iis7

This IIS session out value overrides web.config session time out each time.

One thought on “Set the default Session TimeOut for your ASP.NET application”

Comments are closed.