ASP.Net Login/Logout with Forms Authentication issue

Posted on 2011-10-24
Last Modified: 2012-08-13
I am using Forms Authentication with an ASP.Net website (C#, Visual Studio 2008). If I bring the browser up and login I can get in. When I click the Logout link it goes to the correct page, but if I then try to login again as a different user, I am logged in as the previous user. It seems to be storing the user info and continuing to use it. The only way to log in as a different user is to close the browser and open it again. Any idea how to fix this issue?
Question by:dodgerfan
    LVL 7

    Expert Comment

    Are doing something unusual?  E.g.:

    1) Are your login controls in an UpdatePanel?
    2) Have you disabled ViewState?
    3) Have you messed with the browser cookies?
    LVL 21

    Assisted Solution

    Try putting the following in your logout link event:

    LVL 7

    Accepted Solution

    You may also need this in the chain:


    ...however, I don't think omitting this should cause the behavior you describe.

    Author Comment

    All of the comments had me working through the code to get it working. I was looking in the wrong section. Some redundant stuff I thought I had removed. Once the logout page was redirected to properly, it worked correctly. The On_load event of the logout page runs the Forms.Autrhentication.SignOut(), plus I put session.abandon in it and finishing it by re-directing back to my main page with the user logged out. I've tested it repeatedly and it's working right. Thanks for all of the ideas, they all got me looking in the right area. I'm going to try and divide up the points.

    Author Closing Comment

    All of these comments/suggestions helped me find the solution.

    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 recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 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

    11 Experts available now in Live!

    Get 1:1 Help Now