[英]How can I redirect my action to the root of the web site?
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. 我想将用户重定向到我网站的基本URL(根)。 Is there a way that I can do this without having to give details of the area, controller and action?
有没有办法我可以做到这一点,而不必提供区域,控制器和行动的细节?
if you don't want to use RedirectToAction
(for me is the right choice) you can use 如果您不想使用
RedirectToAction
(对我来说是正确的选择),您可以使用
return Redirect(Url.Content("~/"));
UPDATE UPDATE
As stated in the comments, this should also works 如评论中所述,这也应该有效
return Redirect("~/");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.