ASP.Net logout code block

12,231

Solution 1

You need to make sure that the session is abandoned and call the FormsAuthentication.SignOut() method as shown below:

private void Logout()
{
  Session.Abandon();
  FormsAuthentication.SignOut();
  FormsAuthentication.RedirectToLoginPage();
}

Solution 2

Assuming you're using Forms Authentication, you would just do:

System.Web.FormsAuthentication.SignOut();

Without more information I can't be more specific.

Share:
12,231
JPJedi
Author by

JPJedi

developer

Updated on June 04, 2022

Comments

  • JPJedi
    JPJedi almost 2 years

    I need a good logout code block for asp.net. Currently after you logout you can hit the back button and continue using the site.