ASP.NET Login/Membership - How to logout?

余生长醉 提交于 2020-01-10 20:06:09

问题


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


回答1:


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

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



回答2:


I'll just accept Ira's answer because my question was wrong.

This is the solution to the Umbraco bug:

Add an onloggedout to the LoginStatus

<asp:LoginStatus ... onloggedout="UmbracoLogout" />

that manually clears the cache

  protected void UmbracoLogout(object sender, EventArgs e)
  {
    Member.RemoveMemberFromCache(Member.CurrentMemberId());
    Member.ClearMemberFromClient(Member.CurrentMemberId());
  }

(from http://our.umbraco.org/projects/website-utilities/nforum/bugs/18405-Cache-problem)



来源:https://stackoverflow.com/questions/7831945/asp-net-login-membership-how-to-logout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!