问题
I have the following code in my controller to redirect my user after he has logged out:
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return new RedirectToRouteResult(
new RouteValueDictionary(
new {
area = "Administration",
controller = "Menus",
action = "Home"
}
)
);
}
I would like to redirect the user to / or the base URL (root) of my site. Is there a way that I can do this without having to give details of the area, controller and action?
回答1:
if you don't want to use RedirectToAction (for me is the right choice)
you can use
return Redirect(Url.Content("~/"));
UPDATE
As stated in the comments, this should also works
return Redirect("~/");
来源:https://stackoverflow.com/questions/10291966/how-can-i-redirect-my-action-to-the-root-of-the-web-site