Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to really logout in asp.net

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.

like image 373
mirza Avatar asked Oct 29 '13 07:10

mirza


People also ask

How to make logout in asp net c#?

Just give the href value of logout page. href="Logout. aspx" .

How do I logout of VB net?

You can place a Loguot Button/Menu so that user will click for logout. Now when logout button pressed Just clear all Variables value which you used for storing the session, and then hide this form and navigate to the login form again.......


3 Answers

use FormsAuthentication.SignOut(); as below:

protected void LogoutButton_Click(object sender, EventArgs e)
{
    FormsAuthentication.SignOut();
    Response.Redirect("~/Login.aspx");
}
like image 103
Habibillah Avatar answered Oct 11 '22 12:10

Habibillah


None worked for me but this does.

Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
like image 3
Crismogram Avatar answered Oct 11 '22 12:10

Crismogram


Use Session.Clear() like this:

protected void Button_Click(object sender, EventArgs e)
{
    Session.Clear();
    Response.Redirect("Login.aspx");
}
like image 3
Priya Gund Avatar answered Oct 11 '22 11:10

Priya Gund