将路由值传递给View from Action

haa*_*nsi 0 c# asp.net-mvc asp.net-mvc-4

下面是我的动作代码,它接收一个参数(int id).

public virtual ActionResult Index(int id)
{
    // Logic
    return View("List", id);
}
Run Code Online (Sandbox Code Playgroud)

我的网址是这样的: Home/List/1

我知道我可以退回View("列表"),但不知道如何使用它进行广告ID,请帮助我.

Anu*_*raj 6

您可以使用Controller.RedirectToAction方法之类的东西

return RedirectToAction("List", new { Id = id});
Run Code Online (Sandbox Code Playgroud)