I use LoginControl for login into my website in asp.net, but when for logout use login status or session.Abandon or .sign out ,there's white backspace, my homepage is loaded and its not secure.

Please help me that use realy logout in my project.

有帮助吗?

解决方案 5

I found a solution that I use in my master page

if (Membership.GetUser() != null)
    .....
else Response.Redirect("Login.aspx")

and codebehind for logout button:

FormsAuthentication.SignOut();
Response.Redirect("Login.aspx");

Thanks for your help!

其他提示

use FormsAuthentication.SignOut(); as below:

protected void LogoutButton_Click(object sender, EventArgs e)
{
    FormsAuthentication.SignOut();
    Response.Redirect("~/Login.aspx");
}

None worked for me but this does.

Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

Use Session.Clear() like this:

protected void Button_Click(object sender, EventArgs e)
{
    Session.Clear();
    Response.Redirect("Login.aspx");
}

The home webpage is loading from the browser cache, use the below metadata tags to force the browser to clear cache after exiting the page

<head runat="server">
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="cache-control" content="no-store" />
<meta http-equiv="cache-control" content="must-revalidate" />
<meta http-equiv="cache-control" content="proxy-revalidate" />

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top