Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, November 4, 2008 5:12 PM
I'm doing some testing and am encountering something rather odd. In web.config I have the Session timeout value deliberately set to just 1 minute (only during testing). I'm working the app and am sure that the server is being accessed more frequently than 60 seconds. Yet I just noticed that Session_End in global.asax fired!
Are there some exceptions to the type of server access that would not reset the Session timeout back to 1 minute?
Mysterious!
Robert
All replies (10)
Tuesday, November 4, 2008 6:37 PM âś…Answered
1 minute is quite short. the session gets created before the request hits the page, remember. so what happens, in order is this:
- the request hits the server
- asp.net loads up the httpmodule for the application
- the server checks to see if there is an existing session and if there is, it resets the timer.
- if there isn't an existing session, the session is created
- the server loads up the asp.net handler for aspx
- the request is passed to the page
- the page initialises, loads, renders and sends the response before unloading
- the browser receives all the bits and pieces and renders the page
- you do your stuff
- you post your next request to the server
- back to step 1.
There's a lot happening between step 4 (the first time) and step 3 (the second time). this does not necessarily mean that 60 seconds is elapsing, but it could quite easily. particularly if you're debugging (and even more likely if you're debugging on the first time the page loads).
The main point i'm trying to make is that the session is created as soon as the request hits the server, so your countdown starts there and not when the response goes out to, or is received by, the client.
Tuesday, November 4, 2008 6:57 PM
Bipro,
Thank you for that extensive explanation! When you're wishing to test Session timeouts, what value do you use? 2 minutes, perhaps?
Question: Say I start VS2005 afresh and run my web app in Debug mode. The new session icon appears in the System Tray and then the app runs in the browser. Say I stop the app from VS2005, make some code changes and run it again (really quickly). Is the original session timeout still counting down or does VS2005 reset it back to the full time again?
Robert
Tuesday, November 4, 2008 7:12 PM
yeah. 2-3 minutes, maybe as much as 5 if i'm stepping through the initial request.
Making code changes restarts the app and hence all previous sessions are all dropped.
Tuesday, November 4, 2008 7:18 PM
Excellent. Thank you again!
Robert
Tuesday, November 4, 2008 7:21 PM
My pleasure
Tuesday, November 4, 2008 7:25 PM
Anytime, bro'.
Wednesday, November 12, 2008 12:36 AM
Sorry to bug you again. I've reset the sessionState timeout back to 5. Yet after starting & stopping my app in Debug mode, I swear that the timeout is sometimes occuring in less than a minute. Yet, everytime I re-run my app, I have to login, so I know that the server is being accessed.
Is there something I don't understand about when the Session timeout timer gets reset? I thought it was each and every time I accessed the server.
Any enlightment would be MUCH appreciated!
Robert
Wednesday, November 12, 2008 1:15 AM
no need to apologize, bro'. It does seem like rather peculiar behaviour. can you tell me the exact steps that you're doing to reproduce the issue, and also, the code (or tell me where in the config) that you've used to update the session to 5 mins?
Wednesday, November 12, 2008 1:22 AM
In my web.config file I use this:
<system.web>
<sessionState mode="InProc" timeout="5" />
</system.web>
With VS2005 I'm simply runing my project, testing it, stopping it, making adjustments, and running it again.
Once again, I am logging in each time, so the server MUST be being hit. But in some of these debug sessions, it is absolutely less than 5 minutes after I press "Start" that the Session is timing out. That's what got me wondering when precisely the Session timeout timer is reset to 5 minutes (in my case).
Robert
Tuesday, December 30, 2008 8:44 AM
With VS2005 I'm simply runing my project, testing it, stopping it, making adjustments, and running it again.
This will behaviour will more than likey restart the session...
Hhowever if I am reading right can you confirm this is the EXACT steps you use to recreate this problem?
- make code changes
- run APP from VS2005 in debug mode
- login to your web application locally
- wait a few mins
- find that your session restarts sometimes in less than a minute as you are being logged back out
If this is the case are you use forms authentication and are finding that your "ticket" has expired?
Thanks, Rippo