Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to increase session timeout in asp.net?

Tags:

I tried following codes to increase session timeout, but no use,

code is:

<sessionState mode="InProc" cookieless="true" timeout="60"> </sessionState> 

Also code at

void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started Session.Timeout = 15; } 
like image 216
Pugal kannaN Avatar asked Feb 24 '14 13:02

Pugal kannaN


People also ask

How do I increase server session timeout?

Click Servers > Server Type > WebSphere Application Servers > CongnosX_GW2. Click Container Settings > Session management > Set Timeout. Enter the desired timeout value in minutes. Click OK.

How can increase session timeout in ASP.NET MVC 5?

Open the web. config file, then increase the value in minutes by using the time out attribute of SessionState element. By default, the session timeout value is 20 minutes. Also in your case if you are using forms authentication, please check the timeout value.

How do I increase session timeout in IIS 10?

Expand the local computer node, expand "Web Sites", right-click the appropriate website, and then click Properties. 3. Click the "Web Site" tab. 4.In the Connections area, change the value in the "Connection timeout" field, and then click OK.

Is it possible to manually set a timeout for a session in net?

Yes, we can set the session timeout manually in web. config. In ASP.NET we can set the session timeout in the web.


2 Answers

You can increase the session time-out in asp.net in any one of the following ways

Using IIS Version 7 :

  1. Open up IIS
  2. Select your website from the list of sites
  3. Click on Session state on the right
  4. Now enter your session timeout under the cookie settings

OR

Web.config : Open up your web.config file and under the system.web section add the following :

<sessionState timeout = "20" mode = "InProc" /> 

Replace 20 with whatever number you wish.

OR

Global.asax file : Under the Session_Start method, set the timeout property of the session to the required value like this

Session.Timeout = "20"; 

Note : If you are setting a session timeout in both IIS as well as web.config, then the one in IIS will override the one in web.config

Hope this helps!

like image 86
skywalker2909 Avatar answered Oct 09 '22 16:10

skywalker2909


If you are using forms authentication then the default value of session timeout is 30min.Try this code to increase session timeout.

<system.web>   <authentication mode="Forms">       <forms timeout="70"/>   </authentication>   <sessionstate timeout="80"/> </system.web> 

I think the code help you.

like image 22
Ajay Prasad Avatar answered Oct 09 '22 15:10

Ajay Prasad