In some web environments, closing the web browser will not abandon the current user session. It’s important to create an appropriate logout/logoff action for your application for better security and privacy, especially for users that use in computers and devices.

Below is the “Action” method that can be used inside your controller to kill the logged in session:

Public ActionResult Logout()
{
    Session["UserInfo"] = null;
    Session.Abandon();
    return RedirectToAction("Your login or exit screen", "Your action");
}

Happy Coding!!

Related articles

How Controllers Handle Requests in ASP.NET Core MVC?

 

Last modified: March 6, 2019

Comments

Write a Reply or Comment

Your email address will not be published.