简体   繁体   中英

Why is my session ending?

I have an ASP.NET web application I'm running with VS2010 that has session timeout configured for 20 minutes.
I leave a page running that does an ajax call every 2 minutes and has a defibrillator implemented. With this setup, the session should never expire; and yet I find that 20 minutes later my session is still ending.

Does anybody know why that happens? And more importantly, can anybody tell me how to make sure the session never expires when the user is in that page?


EDIT: I changed the defibrillator so it now executes this code in javascript: setTimeout("location.href = '/Defibrillator.aspx?nocache=" + Math.floor(Math.random()*100000000001) + "';",60000);
Still the same, so it's not a cache issue.
I'm running the site from VS directly (via the Debug "play" button), so it shouldn't be sharing an Application Pool, right?

Have you verified that the javascript is getting executed? Check your access logs to see if the request is there.

Also inspect your cookies - I'd suspect that perhaps the session cookie is not getting updated, so you may need to reload the page occasionally in order to refresh it.

Update: From the comments, it sounds like the session cookie as stored by the browser is not getting refreshed. I'd suggest either reloading the page periodically, and perhaps changing the session timeout. You'll have to balance the two depending on the usage patterns of the app.

In the end I had to resort to adding an autosave feature using ajax.
It's a sad day when StackOverflow can't give me an answer:(


EDIT: I finally found out what was causing the problem... it turned out that in some place in the masterpage the code was calling a rather obscure method that enforced a fixed timeout... so it wasn't anything that you could have helped me with. Sorry about that.

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