Asp.net 如何在controller/action/id中获取id值

Asp.net 如何在controller/action/id中获取id值,asp.net,asp.net-mvc-2,Asp.net,Asp.net Mvc 2,我有一个“编辑应用程序”视图,可以在以下URL找到它: 1等于应用程序ID 在页面上还有一个链接,指向另一个视图,为应用程序添加助手。我想将应用程序ID传递给它,以便新助手可以“链接”到此应用程序。我如何获得1的值并将其添加到我的操作链接?这是我目前在HTML中的内容: <%: Html.ActionLink("Add New Assistant", "Create", "Assistant", new { applicationID = "id" }, null) %> 有

我有一个“编辑应用程序”视图,可以在以下URL找到它:

1等于应用程序ID

在页面上还有一个链接,指向另一个视图,为应用程序添加助手。我想将应用程序ID传递给它,以便新助手可以“链接”到此应用程序。我如何获得1的值并将其添加到我的操作链接?这是我目前在HTML中的内容:

<%: Html.ActionLink("Add New Assistant", "Create", "Assistant", new { applicationID = "id" }, null) %>

有人能给我建议吗


如果您使用默认的路由设置,谢谢

Request.RequestContext.RouteData.Values["id"]
你应该做你想做的

还可以使用ViewData将id从控制器传递到视图

ViewData["applicationID"] = 1; //or ApplicationModel.Id or whatever
在你的视野中使用它

<%: Html.ActionLink("Add New Assistant", "Create", "Assistant", new { applicationID = ViewData["applicationID"] }, null) %>

或者在强类型视图中,使用viewmodel传递id:

<%: Html.ActionLink("Add New Assistant", "Create", "Assistant", new { applicationID = Model.ApplicationID }, null) %>