I have a page under the default /Home/Index. On this page I have a link to log out the user:
@Html.ActionLink("LogOut", "LogOut", new { controller="Users" })
When I click on this link, debugger goes to default controller, that means Home and action Index. This is my routing
routes.MapRoute(
"LogOut", // Route name
"Users/LogOut", // URL with parameters
new { controller = "Users", action = "LogOut" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}", // URL with parameters
new { controller = "Home", action = "Index" } // Parameter defaults
);
What is wrong here? Why it isn't going to the appropriate controller and action?
[EDIT] From js code I can log out the user using
$.post('/Users/LogOut',function(){
window.location.replace("/Home/Index");
});
My LogOut action is simple
public ActionResult LogOut()
{
string login = HttpContext.User.Identity.Name;
usersService.RemoveLogin(login);
usersService.RemoveUsersMessages(login);
System.Web.Security.FormsAuthentication.SignOut();
return RedirectToActionPermanent("LogIn", "Users");
}
but the problem is not with this method. When I click on the link I'm going streight to the default default /Home/Index. Don't know why from client code it works, but using link to send postback to server not.
FormsAuthenticationinweb.config?