I want the Logout link to carry out a process located in HomeController and not to display a new View. How do I go about structuring this?
Controller method:
public ActionResult LogoutProcess()
{
previousLoggedIn = WebSecurity.CurrentUserName;
WebSecurity.Logout();
return RedirectToAction("Logout", "Home");
}
public ActionResult Logout(HomeModels.LogoutModel model)
{
model.PreviouslyLoggedInUsername = previousLoggedIn;
return View(model);
}
View:
<a href = "@Url.Action("LogoutProcess", "Home")">Logout</a>
You can use the standard link, targeting that action
The “trick” is in Redirection to some other View at the end of your
LogoutProcess()action:The
CurrentUserNameis passed to other action viaTempData