1
votes

I want to increase the session timing of my ASP.NET web App hosted in IIS 6.0. So, I changed the SessionState timing to 600 mins in web.config of the site. But it didn't work and my session times out like in an hour.(Session["myVariable"] == null)

<system.web> 
<sessionState timeout="600" />
  </system.web>

Now I tried setting the Timeout value in IIS website where this application is hosted by going to website -> Properties -> Home Directory Tab -> Configuration button -> Options tab and changin it to 600 mins, still no luck. The question here says that this is for classic ASP Pages but not for ASP.NET web sites. which means that I am doing it wrong.

Then I checked the app pool under which this application runs (app Pool->Properties-->Performance tab). This says "Recycle Worker Process(in minutes)" as 10 mins. I read many questions on SO but none of them gives a clear cut answer on how to increase the session timeout on ASP.NET WebApp.

I want to know the difference between these three settings and when to use which and how do we increase the session timeout of my webApp.

1
Note the default in-process session mode is not recommended for production applications because it will recycle session every time the app pool recycles. To prevent this, use one of the out of process session state modes.NightOwl888
So, you suggest to change the Session State mode completely I appreciate and agree with that completely , but that includes a lot of rework on the application as it was huge and was written long ago like 8 years back, and in the long run, we are planing to migrate to Angularjs so, putting huge effort now may not be worth it. Any other solution would be of great help to me. I thought this would be easy, seems like its notProgrammerzzz
Read the documentation. There is no "rework", it is only a single web.config configuration setting and setting up the state server (either in SQL server or as a Windows Service).NightOwl888
Apologies if i am not clear.I know its a small change in web.config.but i meant changing the way we access the session variables across the whole app is tedious and laborious.Programmerzzz
Okay...do u have an example that i can look at? It would help me to get startedProgrammerzzz

1 Answers

0
votes

The timeout you set in your web.config is the session timeout. It controls how long each 'session' of your web app needs to wait before expiration. Let's say one user logs in to your app and does nothing for 20 minutes and then clicks a button, he will be logged out and needs to login again (assume session timeout is 20 mins). Any other users who were continuing their work won't be affected.

App pool recycling is a different thing. It's a setting which kills and restarts the worker process in IIS as instructed. So if you have it set for 10 minutes, it's like you are restarting IIS every 10 minutes. So all sessions in apps which uses that app pool will get expired unless you have sessions state saved elsewhere.

There is another setting in app pool, which is the idle timeout. It's also set in minutes and it also terminates the worker process if there are no requests for that time period. If you have only your app running in IIS, then you should increase this value as well, along with your session timeout value in web.config. Otherwise even though ASP.NET likes to keep its sessions for long, the app pool won't.

This setting is found in app pool -> advanced settings -> process model