Search code examples
asp.netauthenticationasp.net-membershipumbracologin-control

ASP.NET Login/Membership - How to logout?


I am using the <asp:LoginStatus> control (along with <asp:Login>)

I login successfully as A.
Then I logout.
If I then login as B, the current user is still A.
(Both <asp:LoginName> and HttpContext.Current.User.Identity.Name are showing A)

I have to clear the cookies to completely logout.

Why doesn't the .NET login control log me out properly? Anyone has any idea?

EDIT: I apologize everyone! This is an Umbraco bug. I forgot I was using UmbracoMembershipProvider


Solution

  • On logout to completely clear out the logged in user I would use:

    Session.Clear()
    Session.Abandon()
    FormsAuthentication.SignOut()
    FormsAuthentication.RedirectToLoginPage()