Logging out is an important step when it comes to security. Simply closing the browser may not clear the data you were accessing. Below is a function that you use from inside a controller to log out the right way.

Log out action in MVC

public ActionResult LogOut()
{
    FormsAuthentication.SignOut();
    Session.Abandon(); 
    return RedirectToAction("index", "home");
}

Happy Coding!!!

Related Articles

Create a newline in rich text box in C#

Bind Countries to a DropDownList in ASP.NET using C#

Check for Even or Odd Number Using C#

 

Last modified: February 22, 2019

Comments

Write a Reply or Comment

Your email address will not be published.