Powered by Blogger.

Thursday, March 13, 2014

How to increase session timeout period in asp.net?



In this article we will discuss How to increase session timeout period in asp.net ?
You can also check my previous articles on:

- Query to get records between two dates in sql server 2008

- Method Overloading in C#.Net

- WCF interview questions and answers in C#.Net

By default session timeout is 20 minutes but sometimes it is required to increase or decrease the session timeout as per application requirement. It is possible by a simple setting in the web.config file.

let's say we have to  increase session timeout to 60 minutes then make changes in the web.config files as:

We need to add some lines of code in the web.config file.There are different ways to set this.

Way-1
<system.web>
<sessionState timeout="60"></sessionState>
</system.web>

Way-2
<system.web>
 <sessionState mode="InProc" cookieless="false" timeout="60" />
</system.web>

Way-3
<system.web>
<sessionState
    mode="InProc"
    stateConnectionString="tcpip=128.0.0.1:42424"
    stateNetworkTimeout="60"
    sqlConnectionString="data source=128.0.0.1;Integrated Security=SSPI"
    cookieless="false"
    timeout="60"/>
</system.web>