通常,路由到任何控制器的 Index 操作的 ActionLink 将省略链接中的“Index”,即http://localhost:8080/Controller/id
. 就我而言,我试图将字符串作为 ID 传递给 Eta 控制器的 Index 操作。代码如下:
@Html.ActionLink(item.Name, "Index", "Eta", new { id = item.Name }, null)
结果链接显示为:http://localhost:8080/Eta/Index/some-input-string
而不是http://localhost:8080/Eta/some-input-string
此 RouteConfig 与 File>New Project>MVC4 Application 完全相同。