Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Postback automatically after session timeout

Here is our application requirement.

Our web application which is going to be developed in asp.net should have the capability to refresh automagically after the session timeout(say 20 mins) and save whatever the data entered so far.

Two possible solution is

1. Keep Javascript block which has the timer function to post back the page without asking the user

2. Keep Javascript block which has the timer function to post back the page and also provide an alert to the user about this postback and ask them to choose one option(ok/cancel).

And then do the saving part in the code behind and redirect them to main page. Any of you already done this? any better idea?

thanks in advance
Ram

Ram
Wednesday, July 28, 2004

Why would you want it to do that ?

Also, how will the JavaScript know that the session has expired ? Just firing off a timer after twenty minutes may not be enough.

Nemesis
Wednesday, July 28, 2004

If you need to do something when the session ends, why not just hook into Session_End?

Greg Hurlman
Wednesday, July 28, 2004

Odd, I did some googling on this for a coworker just last week.  Here's what I sent him:

links on javascript and timing:

using javascript to autorefresh the page and keep session alive:
http://groups.google.com/groups?selm=u1J%232L%246DHA.2524%40TK2MSFTNGP11.phx.gbl&output=gplain

using javascript to pop up a warning when session is near expiry:
http://www.aspfaq.com/show.asp?id=2265

Good luck.

Matt Conrad
Wednesday, July 28, 2004

Oh, and I guess I was really answering the question you weren't asking.

Really depends on the details of your app, but my inclination would be, if I were going to do this at all, I would do it silently and not bother the user with it.  (This is OK if you merely have silent saving of data.  Not OK if you are then going to redirect to another page, though.)

Matt Conrad
Wednesday, July 28, 2004

I would kick back on this one. My gut feeling is that if a user enters data in a form and then doesn't click save for 20 minutes then they need to learn the error of their ways. Of course it might be quite reasonable if your forms are complex (althougb that raises other questions about the app's design).

Ultimately the result of doing an "automatic postback" as you suggest is that infact the Session won't actually time out - how about just lengthening the Session timeout period perhaps?

Duncan Smart
Wednesday, July 28, 2004

I didn't understand why you'd wait until after the session had expired. Surely, then you've lost your context anyway, so you'd have to log back in.

Perhaps it was lost in translation ;-)

Nemesis
Wednesday, July 28, 2004

Thanks guys for the input.

As we have large chunk of input to be made for every step, it is taking more than 20 mins to complete one case and so we are going with this approach even though we do not like this approach particularly.

We also have one option of "save as draft" functionality and no validation is done in this case and information will be saved as it is. So in case of long inactivity, user input needs to be saved without any validation as if they pressed "save as draft" button manually.

We also evaluating "silent saving" approach using XMLHTTP

thanks

Ram
Thursday, July 29, 2004

*  Recent Topics

*  Fog Creek Home