Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net logout code block

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.

like image 450
JPJedi Avatar asked Jun 11 '09 14:06

JPJedi


People also ask

How to code logout in ASP net?

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


1 Answers

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();
}
like image 172
Jose Basilio Avatar answered Sep 20 '22 11:09

Jose Basilio