Monday, February 26, 2007

.net session timeout settings in IIS6 on windows 2003 server

Does this sound simple web.config setup?
Nope this is way beyond that newbie configuration.

Problem: We were facing timeout issue on one of our servers. Web.config settings had no effect on the time out.

Note: In all screen shots pink color is hiding the actual server details.

So here are some more interesting findings related to timeouts of sessions in IIS6 hosted on a windows 2003 server. You may need to change one or more of these setups in your server according to your setup.
There are totally 5 setups that influence your timeout. All of those are discussed here.
1. Web.config file of Application: First one to influence timeout is Session timeout setting in your we.config file.

Note: Web.config file is inherited to the subfolders and subfolders config settings take the precedence in case they exist.

2. Application session timeout in IIS:
Go to IIS, right click on the web application, go to properties. Go to Directory tab, click on Configuration button. Application configuration tab opens, click on Options tab as in the screenshot, you will find enable session state. Change the session time out period here.

3. Default website session timeout in IIS: Right click default web site under IIS and choose Home directory tab. Click on configuration button to open application configuration. Choose options tab and you will find Enable session state again similar to session state of each application. Enter higher session timeout period which will be application to all sites in the webserver.

4. Change Worker process idle timeout of application pool – Shutdown worker process after being idle for (time in minutes) – Default is 20 minutes. This setup is applied for all websites that use this application pool. To change this, Right click on the required application pool, choose Performance tab, and change the duration of idle time or uncheck the option so that the process is never recycled. You can also create an application pool, configure it, and use it for a selected list of web applications.

5. Change Recycle timeout period of application pool: Right click on application pool or default application, and choose Recycling tab. Change the “Recycle worker process (in minutes)” option to either change the period or disable the option by un checking. Un checking this option may be a good idea from performance point of view.

And finally there is a last one in machine.config file. But that does not affect any of these configurations and these setups take the precedence.

Let me know if you have any timeout related issues. Lets share.


Anonymous said...

This information has been very helpful to me. I had all the settings set in web.config but it didn't have any effect on session timeout. After changing the settings in IIS as mentioned in the article... The application runs without any glitches...

Thanks a lot...

sanjaykattimani said...

:) I am glad it helped you.

Shane Warta said...

Hi Sanjay,

I came across your article regarding IIS settings and was wondering if you had any recommendations on a site that uses sessions extensively rather than cookies. You state that application pool setting should be modified but don't include any values. My question is what is the balance of time vs memory consumption. I have 4 gigs of memory on my server and need your rec on the values that I need to change in the application pool.

Any insight would be appreciated.

sanjaykattimani said...

Hi Shane,

Sessions should be used sparingly as they take up lot of resources and till session expires. If they are already used extensively, consider reducing the session timeout period specially if you have lot of visitors to the site. Also note that reducing the timeout to a smaller value frustrates the users.

Before increasing or decreasing the timeout values, i would suggest you to first study the user base, time taken for processing the request and the response time of the server. Ideally session should time out from 15-20 minutes.

In the example that i have shown on my blog, we just wanted to increase it to 90 minutes and various IIS settings were not letting us achieve the same as documented.

Rajani Kanth said...

Dear Sanjay,

I really like you explaination, no other document on the net can beat it.
However, I did follow everything that you mentioned. I set the timeout as 90 minutes on IIS.
I've set the timeout to 120 minutes in the web.config.

But the session timeouts are sooo random. I've been on this for 4 days now, can't figure the problem.
Is there anything that I should be looking.

Thanks in advance

Anonymous said...

We had "InProc" session management and the sessions would drop very randomly.

We had a process which was logging the time and date the daemon process was run. See the below link, of what it has to say!

if any file in the application's directory changes, the session would be lost!
Strange but true, MSFT calls it a feature, but honestly I think this is a flaw in the “InProc” session management of MSFT IIS 6 Server.

1.Change the session management algorithm
2.Don’t update or create any files in the application server directory

Any questions please feel free to email me

Hopefully, this will help

sanjaykattimani said...
This comment has been removed by the author.
sanjaykattimani said...

:) Being in to software industry is all about learning and fixing new kind of issues..

k.c. said...

Wonderful wonderful

It helps me lot

many many thanks

Andrew Wiley said...

Prepared at the Request of Counsel

Thank you very much for your artticle, ".net session timeout settings in IIS6 on windows 2003 server."

Configuring our server using your instructions solved our problem where, no matter what web.config settings were for the session timeout property, we still would experience session time outs after 20 minutes.

I only wish Microsoft's knowledgebase was as clear and complete on this issue. I must have read through about 50 pages before finally finding yours, and I immediately knew that your instructions were going fix the problem Again, thank you so much, and I am bookmarking your blog for future reading!

Andrew Wiley
Project Manager
******** Team
Office # ***-***-****
Cell # ***-***-***

Anonymous said...


It’s really a nice article. Thanks for sharing information. I have one question is there a way to handle session timeout value in application code, I am considering hosting on public server were we don’t have access to IIS or application pool. And changing a value in the Web.config is not helping out. Is there a way to manage timeout.
Thanks in advance.

Aryo said...

Cek Web Garden settings in Application Pool, if the value of Max number workers greater than 1 (1 is default value). You better use SessionState as Session Storage management, do not use InProc session since your session will lost randomly

sanjaykattimani said...

If you do not have access to webserver's configuration, you have very few options left out with you. This is specially true if you are on publicly hosted server. You can only control session timeout less than whats defined on the server. Lets say your server configuration is set to 30 mins all you can do is set it less than that. If you set anything beyod 30 mins, server will anyway kill the sessiion.

Anonymous said...

Great article.....very detailed and resolved the problem 110%, very well done.

Ram said...


how to redirect to a custom page on session time out?

Anonymous said...

So what is the order of precedence?
If the web.config timeout is 90mins and Default Website session in IIS has 30 min, and the Application IIS setting is 15 min - what happens? (Running only (.aspx pages))

gonzalo said...

Hi Sanjay,
I found your paper quite useful, but I still have an issue with the app.configuration session state, the second you stated in your article, i need to change the default value by code, while i am installing the site. i´ve already changed the authorization values with a custom action and i would like to add code to modify the app.configuration session state. could you help me out please. thanks in advance. ggoonn

Anonymous said...

Absolutely great post. Thanks for sharing it in an organised way.


Anonymous said...

really nice article about session timeout in page.thanks for your help.
By Pachayappan.c

Anonymous said...


I figured it out! I will post it here for others

1. Very important, we should not changed the timestamp of ANY file in the bin directory. Eg: We were creating the log file in the bin folder and that was killing the session.
2. The worker process as explained by Sanjay helped. We should not enable the Worker process unless we feel the application is having memory leaks or runs in infinite loop in general if we feel that the app is problematic.


Anonymous said...


I figured it out! I will post it here for others

1. Very important, we should not changed the timestamp of ANY file in the bin directory. Eg: We were creating the log file in the bin folder and that was killing the session.
2. The worker process as explained by Sanjay helped. We should not enable the Worker process unless we feel the application is having memory leaks or runs in infinite loop in general if we feel that the app is problematic.


Anonymous said...

thanx Sanjay :) that was very helpful

Kerwin said...

Have u encountered a similar problem like this:

We have an IIS6 server which accesses a websphere server using a websphere plugin.

If the application is accessed thru the IIS6 server, everytime the page submits, the session is lost and a new session is created.

However, it works fine when accessing the app thru the websphere server directly (Sessions are not lost).

Any idea on how to resolve this? Any help would be greatly appreciated.

Anonymous said...

Hi Sanjay,

My application is in .NET framework 2.0. we wanted to change the forms authentication timeout from 30 minutes to one hour. We made the changes in the web.config but it didnt help. It is getting timedout and going back to the login page after 30 min. We tried to make it less than 30 min. It worked then. Is there any maximum limit for the timeout in .NET 2.0? Please reply.

Anonymous said...

I am facing problem of session time out. I want to maintain session upto 6 hours and i did settings in web config file and IIS but its not working. Its working in on local server but not working on Production ( webserver). Actually we have two webserver for running web application. Can it create problem ?

Jack Bhanded said...

Hi Sanjay,

May God bless you! Thank you so much for this great post!!

I had the same random timeout problem on iis6 and win2003. We have several sites hosted on the same iis server. The problem didn't go off until i removed the worker process shutdown checkbox in the Main pools properties.

Keep up the good work!!!


santhiya said...

Hi Sanjay,

Your document is really helpful. but we've tried all these steps in our server. but still we are facing time out problem. Is there any other chance to override session timing(thro' code)? please advise.


raja said...

Really gud article Sanjay

peter said...

Thanks a lot. I hav never think about the session timeout problem could com from IIS.

San Nayak said...

It helped me as well. I was wondering about it, i was using custom code to set the set the session timeout in asp and it was not listing it for some reason then I had to look into the server setting with this article's help. It is good to go now. Thanks..

Danny said...

If you experience random timeouts for your sessions (ie timeout quicker than specified in sessionstate and idle timeouts), you may want to check if your application pool in IIS 6.0 has any 'Memory recycling' values selected and they are set up to some low sizes both for virtual or used memory.

If e.g you have 200 Mb and the application reaches that limit in 5 minutes (e.g) the recycle happens and any sessions are killed sooner than expected...

Shaily said...

Thanks a lot.

The article is really fruitful.It helps me to solve the problem.The good point is that everything is available in one article.

Anonymous said...

Hi Sanjay,

It is really Excellent and helpful.
Thank you so much....

Rubitha said...

i often get a error like "unhandled win32 exception occured in u want to debug using the selected debugger?".
If i give no the application/explorer will get closed.can u tell why this is happening?

Rubitha said...

i was searching this solution for a whole day and finally i got it..thanks a lot.

Anonymous said...

This blog was quite helpful, but I am facing 1 more problem. When I paste any file in the root folder or any of the subfolder of my web application, all the sessions on the web server gets flushed out immediately.
-- Anuj D.Vaijapurkar
.Net Developer

Anonymous said...

Nice post addressing session timeout issues

Vladimir said...

Justyn said...

Fantastic article, thank you. This solved a days-old problem I was struggling with.

You might revise the original to include SRI's information about changing files in the bin directory; I see there is still a lot of confusion on this.

Brad said...

Thanks for your article, Sanjay.

I would like to share the problem I had, which is related to your point #1 - I confused the "sessionState" section with the "authentication/forms" section of the web.config - they both have a timeout value. I couldn't get my session timeout to go above 20 minutes, then I realized that I didn't have the "sessionState" section in my web.config - I had been changing the "authentication/forms" timeout value.

hannan said...

I am working on this issue "timeout issue on one of our servers",for long time ,At last ,find the solution from your blog ,thanks for your exlanation.It gave me a good help .I shared it with more and more people in my folder ,my-dig.
HOPE those who need it could find it.

Rene said...

Thanks is have been like 3 month of research and looking what was wrong and finally working. I change the web option and in application I use plesk control panel so I change the option for plesk and now is all working Thanks.

Anonymous said...

Hi Sanjay,
Thanks for such a wonderful info. I am facing same problem i.e. random timeout and i have also checked all the options. Everwhere it is set to 20 minutes but currently we are facing random timeouts may be within 5-10 mins. What would be the reason?
I am using ASP.NET 2.0, IIS6 and SQL Servwer 2005 for storing session state.

Please help.

Anonymous said...

HI Sanjay...what a great post!!! after 2 hours of research and contradictory statements from various websites, i bumped across this one and it resolved our problem in minutes!!! thanks again, Pete

GavinR said...

Hi, having read your post I just wanted to point out that the IIS settings for Session Timeout are related to ASP and not ASP.NET.

sanjaykattimani said...

I am glad that this blog was useful to you guys.

Anonymous said...

What are other side effects if we put 90 mins in Enable Session state,recycle work process etc.

Appreciate any help.

Thank you.

Anonymous said...

This Blog is very nice and useful.
We have one problem in my site. We have not set any session timeout constraint in my site.(Not in Web.config file or any where)
We have just set session timeout in IIS worker process is 55 min.
Now, we are gating server timeout problem sometimes. Its not every time that we are gating this problem.
Can you please gives us your views regarding this?

Thanks Sanjay

Anonymous said...

Hi Sanjay,
My web application runs under web-farms and application-pools also used. On production servers session time out works shortly than local machine and test server. All configurations seems identical, the only difference is of web-farm is used on production-servers. What could be the problem? i have checked the application pools too. Please help.

Anonymous said...

Your blog is very useful.My application is working on local server.its settings are
web.config - 600
application session timeout in iis -700
default website session timeout in iis -700
worker process idle timeout out of application pool-800
recycle timeout period f application pool -1740
Is anything wrong with this settings?
i am getting log out problem twice or thrice in a week.what could be the problem?Thanks in advance.

Rajiv said...

Thanks, this is very helpful.

Mitch said...

Track Back -


Anonymous said...

I have Classic ASP Website hosted on IIS6 (Windows Server 2008 Standard) and facing same session time out issue.

Anonymous said...

I have Classic ASP Website hosted on IIS6 (Windows Server 2008 Standard) and facing same session time out issue.

alpatel said...

Hi sanjay,
Thanks for useful information.
I have facing problem bellow now.
session state working locally but not work some time on iis 6 web server.

Sanjay Kattimani said...

Sorry guys its been some time that i stopped development on this platform hence not been answering questions.