How can I set infinity session time out in asp.net project

You cannot assign it to unlimited. You can increase the value in minutes using the time out attribute of Session state element in web.config

<sessionState timeout="30">
</sessionState>

By default session timeout value is 20 minutes. Also in your case if you are using forms authentication, check the authentication time out value as well

<authentication mode="Forms">
   <forms loginUrl="logon.aspx"  protection="All" path="/" timeout="30" />
</authentication> 

one way is by setting the timeout in web.config file. Like

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

The other way is by setting the time-out in server side code in .cs file. Like

Session.Timeout = 100;

The time-out value entered will be read as minutes. If set to 0, then there will be an error page displaying session time-out value cannot be 0 and must be >0.


You can set session timeout in web.config as shown below. The value is showing minutes, so you can set as long as you want, up until a year.

    <configuration>
      <system.web>
         <sessionState timeout="200"></sessionState>
      </system.web>
    </configuration>

The Timeout property can be set in the Web.config file for an application using the timeout attribute of the sessionState configuration element, or you can set the Timeout property value directly using application code.

The Timeout property cannot be set to a value greater than 525,600 minutes (1 year). The default value is 20 minutes.