Redirect to Action in another controller

前端 未结 5 638
暗喜
暗喜 2020-11-30 19:39

I have two controllers, both called AccountController. One of them, lets call it Controller A, is in an Area called Admin

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 20:13

    Use this:

    return RedirectToAction("LogIn", "Account", new { area = "" });
    

    This will redirect to the LogIn action in the Account controller in the "global" area.

    It's using this RedirectToAction overload:

    protected internal RedirectToRouteResult RedirectToAction(
        string actionName,
        string controllerName,
        Object routeValues
    )
    

    MSDN

提交回复
热议问题