Developer Forum »
Problem logging out in Mvc project
14 posts

Hi

I'm building a mvc webnodes site with user logins, and I have trouble logging the user out after he click the logout link.

After the logincontroller authenticate the user, I set the auth cookie:

FormsAuthentication.SetAuthCookie(user.UserName, false);
WAFContext.LogInView(user.UserName);

And in my logout action I do this:

public ActionResult Logout() {
	FormsAuthentication.SignOut();

	return Redirect(WAFContext.GetUrl(WAFContext.Session.GetSite().StartNode.GetId()));
}

But it does not log the user out.

14 posts

Hi

I think I found the solution.

public ActionResult Logout()
{
	FormsAuthentication.SignOut();
	Session.Abandon();
	WAFContext.LogOffView();
	return Redirect(WAFContext.GetUrl(WAFContext.Session.GetSite().StartNode.GetId()));
}

I had to add the LogOffView().

(I don't use the LogOffViewAndRedirectToFrontpage() because then I have to add a View for this action)

1