簡體   English   中英

如何將我的操作重定向到網站的根目錄?

[英]How can I redirect my action to the root of the web site?

我的控制器中有以下代碼,用於在用戶注銷后重定向我的用戶:

public ActionResult Logout()
        {
            FormsAuthentication.SignOut();
            return new RedirectToRouteResult(
                new RouteValueDictionary(
                    new {
                        area = "Administration",
                        controller = "Menus", 
                        action = "Home" 
                    }
                )
            );
        }

我想將用戶重定向到我網站的基本URL(根)。 有沒有辦法我可以做到這一點,而不必提供區域,控制器和行動的細節?

如果您不想使用RedirectToAction (對我來說是正確的選擇),您可以使用

return Redirect(Url.Content("~/"));

UPDATE

如評論中所述,這也應該有效

return Redirect("~/");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM