Sunday, August 5, 2012

Set Session TimeOut In ASP.NET


We can Set or Manage Session Timeout in Following ways:
  
1.      Set Session TimeOut in Web.Config
We can set session timeout in SessionState section of web.config file as mentioned below, timeout value is in minutes.
<system.web>
    <sessionState mode="InProc" cookieless="false" timeout="15">
    </sessionState>
</system.web>
  
2.      Set session timeout in Global.asax

void Session_Start(object sender, EventArgs e)
{
  // Code that runs when a new session is started
  Session.Timeout = 15;
}


  
3.      Set session timeout in IIS.

Open IIS manager by typing inetmgr and in Start > run in windows.

Right click on websites > Select Properties.


Go to ASP.NET tab, Click on Edit Configuration.
Click on State Management Tab, Set Session TimeOut value (In Minutes).