I've searched many times for the best method to detect session time in an
ASP.NET 2.0/3.5 web application, however, the ones I've found did not have
option to continue session.
Could anyone point me to a code link that:
1. Detects session timeout.
2. Pop up a Yes/No dialog that allows user to continue session, then time
out completely if no response is made within a set time of minutes.
Thanks,
James
> I've searched many times for the best method to detect session time in an
> ASP.NET 2.0/3.5 web application, however, the ones I've found did not have
> option to continue session.
Indeed not, and for fairly obvious reasons!
> Could anyone point me to a code link that:
> 1. Detects session timeout.
> 2. Pop up a Yes/No dialog that allows user to continue session, then time
> out completely if no response is made within a set time of minutes.
Step back a second here and think why the session is timing out... It's
because there has been no requests from the client browser with the session
timeout period, by default 20 minutes. And why might that be? Almost
certainly because the user has closed their browser, or moved to another
website, or simply gone to lunch or whatever. Remember - closing the browser
or moving to another website DO NOT cause the session to terminate...
So you're never going to be able to pop up a Yes/No dialog - that's just not
the way that web apps work. There is no permanent link between the web
browser.
E.g. if someone sends a web request to your site by visiting it, a new
session is created and your site will send back a web response. And that's
it! Nothing further will happen until / unless the user sends another web
request to your site. If they close their browser, move to another site, or
simply walk away, your site has absolutely no way of knowing that...
It is, of course, possible to increase the session timeout, though that
needs very careful consideration.
It would probably be better if you provide more of an explanation about what
you're actually trying to achieve here.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Simply I want to avoid the exception errors that occur when session
variables become null after the timeout.
James
"Mark Rae [MVP]" <ma...@markNOSPAMrae.net> wrote in message
news:#iZxg8kf...@TK2MSFTNGP05.phx.gbl...
[please don't top-post]
>> It would probably be better if you provide more of an explanation about
>> what you're actually trying to achieve here.
> Simply I want to avoid the exception errors that occur when session
> variables become null after the timeout.
if (Session["MyVariable"] != null)
{
// session variable exists, so use it
}
else
{
// session variable doesn't exist, so do something about it
}
Also, see:
http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=IsNewSession
Mark,
This is not what I am looking for. I can't go in and write code like that
all over the application within the context of first my post! This has to be
a global (application wide) solution.
Anyway, thanks for the links; that helped.
James