问题
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