如何重定向到另一个动作或路线?

How to redirect to another action or route?

在我的 Razor 代码中,我有以下操作 link。

@Html.ActionLink("poof", "Poof", new { Id = Model.Id })

我想要发生的是调用 Poof 方法,然后我希望计算机导航到另一个视图 - 例如显示.

public ActionResult Show(Guid id)
{
  return View(...);
}

public void Poof(Guid id)
{
  ...
  RedirectToRoute("Show", new {Id = id});
  RedirectToAction("Show", new {Id = id});
}

我已经尝试了 RedirectToRouteRedirectToAction 但在这两种情况下,我都进入了一个空白屏幕。仔细查看 URL 表明我被困在 .../Poof/... 路线而不是被带到 。 ../Show/... 我不知道如何跳到合适的 link.

我正在关注 this answer but since the break-point in Show action isn't hit on (on redirect, that is), I start to wonder if it's more appropriate to play around with route mapping like this blog

即使 Poof 正在重定向到另一个动作,它本身仍然是一个动作,因此它需要 return 和 ActionResultRedirectToAction return 就是这个原因 ActionResult

public ActionResult Poof(Guid id)
{
    // ...

    return RedirectToAction("Show", new {Id = id});
}