We help IT Professionals succeed at work.

ASP.NET InProc Sessions expiring too early.

midavis
midavis asked
on
Medium Priority
1,078 Views
Last Modified: 2007-12-19
I am having some issues with web sessions expiring too early.  I am using an InProc Session State Management.

Currently I have the asp.net 2.0 application running on Windows Server 2003.

I created a new applicationp pool for this application and set the "Shutdown worker processes after being idle for..." to 120 minutes.

I have set the Session Timeout in the web.config file to 120 minutes.

I even set the Session Timeout in the Configuration -> Options section to 120 minutes.

For some reason the sessions expire after 30, 20 and sometimes even 10 minutes.  Can someone give me a solution as to why this is happening?
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Is your application recycling?  Are you trapping the Session.End event in global.asax?

Bob

Author

Commented:
Yesterday I put in some logging for when the application ends but no emails for it yet.  I would really like to be able to log each session start by session id in a log file and when the session ends by session id in a log file to see how long the sessions are lasting.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
You can log those from the global.asax file in the Session_Start and Session_End handlers.

Bob

Author

Commented:
How so?  The sender object does not have what I need and the EventArgs give me nothing.  I would like to be able to log the session id when it starts, ends and the length of time it is going.

However, how is this going to fix my problem?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
That won't help you necessarily, so that is why I was asking if your application is recycling, since that will give you a new session.  Application recycles are written in the log.

Bob

Author

Commented:
I don't see anything in the event log stating this.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
I found what I was really looking for:

PRB: Session variables are lost intermittently in ASP.NET applications
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q316148

HTH
Bob

Author

Commented:
I will see if the server has antivirus software somehow.  I know we didn't install anything yet and I am not sure if the hosting company has anything running.

Author

Commented:
Also, if this was the case wouldnt the event log show the server restart?  I am not seeing this.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Here is another reference:

Use Performance monitor -> ASP.NET -> Application restart counter on daily base.
http://weblogs.asp.net/ngur/archive/2003/11/24/39536.aspx

Bob
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Since you are using IIS 6.0:

Logging Worker Process Recycling Events in IIS 6.0 (IIS 6.0)

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/87892589-4eda-4003-b4ac-3879eac4bf48.mspx?mfr=true

Bob

Author

Commented:
I don't see an easy way to install these counters though.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
1) Open the performance monitor (perfmon)

2) Add a counter

3) Select Performance object = ASP.NET

4) Select Application Restarts

Bob

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.