Reputation: 766
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.
Upvotes: 5
Views: 47763
Reputation: 156
Use Session.Clear()
like this:
protected void Button_Click(object sender, EventArgs e)
{
Session.Clear();
Response.Redirect("Login.aspx");
}
Upvotes: 3
Reputation: 936
None worked for me but this does.
Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
Upvotes: 3
Reputation: 766
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!
Upvotes: 1
Reputation: 5892
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" />
Upvotes: 3
Reputation: 28685
use FormsAuthentication.SignOut();
as below:
protected void LogoutButton_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
Response.Redirect("~/Login.aspx");
}
Upvotes: 9