2
Reply

How can I detect an ASP.NET expired session?

Sapna

Sapna

Jan 25, 2011
7.4k
0

    I have a site where the session needs to timeout because of security
    concerns. I want to send the user back to the login page if the session is
    expired.

    Whats happening at the moment is that objects that exisit in the Session are
    being accessed when the session has expired.
    I know I could do an if Session["whatever"] != null or something similar to
    detect whether the object is or isnt empty but there are many objects that
    would need to be checked and I'll bet that some of them can be null quite
    legitimately without needing the user to sign in again.

    Question: Is there a way of doing something like:

    if(Session.IsExpired){
    // Redirect to login
    }
    else{
    // Continue
    }

    krishan kumar
    January 27, 2011
    0
    knights
    January 25, 2011
    0