Introduction:
Here,
I will explain how to set or increase session timeout or expiry time in
webconfig file or in application.
By
default session timeout is 20 minutes but sometimes it is required to increase
or decrease the session timeout as per application requirement.
So
we can set custom session timeout in webconfig or global.asax file in application.
Suppose we want to increase
session timeout to 1 hour using webconfig file:
Then add following code in
web.config file :
<configuration>
<system.web>
<sessionState mode="InProc" timeout="60">
</sessionState>
</system.web>
</configuration>
OR
<configuration>
<system.web>
<sessionState mode="InProc" cookieless="false" timeout="60">
</sessionState>
</system.web>
</configuration>
In Global.asax : Set Session time out on Session_Start event:
void Session_Start(object sender, EventArgs
e)
{
// Code will run when a new
session is started
Session.Timeout = 15;
}