Detecting Session and/or Authentication Timeout

Posted on 2006-04-26
Last Modified: 2011-04-14
I have an ASP.NET application which is configured for Forms-based Authentication and has a simple Login.aspx page.  If a user's session or authentication times out, clicking on any of the application's links takes them immediately to the Login page.  This is fine, I can always adjust the timeout values if it gets too annoying.

However, I would like to display a message telling them what happened ("Sorry, your session timed out.  Please log in again.") because I'm sure there will be some (many?) users scratching their heads when this happens.  Is there a way to detect that the login.aspx page was invoked because of a timeout as opposed to a user loging in for the first time?
Question by:michaelrenda

    Accepted Solution

    Sure, save a session cookie in the browser. It should exist for as long as the browser is open and expire when the browser closes (the default when no Expires timespan is set).

    Author Comment

    This works pretty well except when the user navigates away from the site and then returns.  Because the session cookie is still present, you can't tell the difference between this situation and a session timeout.  Still, it works 90% of the time

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now