简体   繁体   中英

IIS 6.0 Session Timeout Vs Web.Config Timeout Vs App pool Idle time out

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM