Hi,
Jerry said:
I have seen several articles about this subject but I was wondering with ajax
is this easer. The articles mentioned client callback and the onbeforeunload
event of the browser. Can AJAX be used for this and are there any examples to
review.
Thank you
The browser events are not reliable (and also not all are cross-browser
compatible). So using a onunload or onbeforeunload to end the session is
not fool proof.
If you want a sure way, you must use a kind of heart beat. Have the web
client call a web method (might be as simple as a ASHX custom handler
call). As long as the heart beats, the session will not end. If the
heart stops beating, then the session will end automatically after the
Session Timeout set in the web.config. If you want the session to end
immediately, then you'll need to implement some more code, for example a
working thread checking periodically which hearts are still beating.
However, if you set a session timeout of 2 minutes, and the heart beats
every 1 minute, then the waiting time is not that big, and you get the
session to end automatically.
HTH
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog:
http://www.galasoft-LB.ch
PhotoAlbum:
http://www.galasoft-LB.ch/pictures
Support children in Calcutta:
http://www.calcutta-espoir.ch