Session Timeout Detection and Continue Session if Needed - Best Method ?

Discussion in 'ASP .Net' started by James, Dec 15, 2009.

  1. James

    James Guest

    Hi,

    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
    James, Dec 15, 2009
    #1
    1. Advertising

  2. James

    James Guest

    Mark,

    Simply I want to avoid the exception errors that occur when session
    variables become null after the timeout.

    James

    "Mark Rae [MVP]" <> wrote in message
    news:#...
    > "James" <> wrote in message
    > news:...
    >
    >> 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
    James, Dec 16, 2009
    #2
    1. Advertising

  3. James

    James Guest

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "James" <> wrote in message
    > news:...
    >
    > [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 Rae
    > ASP.NET MVP
    > http://www.markrae.net


    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
    James, Dec 16, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Do
    Replies:
    2
    Views:
    6,363
  2. bruce barker

    Re: ASPX Page Timeout - Session Timeout

    bruce barker, Jul 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    11,109
    ASP.Confused
    Jul 20, 2004
  3. =?Utf-8?B?Q3JhaWc=?=

    formsauthentication timeout & session timeout

    =?Utf-8?B?Q3JhaWc=?=, Aug 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,644
    =?Utf-8?B?RU5JWklO?= .enizin.net>
    Aug 10, 2005
  4. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,268
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,279
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page