为什么会这样
<%=Html.ActionLink("Users", "Index", "Users", new { id = "3" })%>
指向此
http://localhost:1798/Users/Index?Length=8
而不是这个
http://localhost:1798/Users/Index/3
注册路线方法:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Users", action = "Index", id = "" } // Parameter defaults
);
}
答案 0 :(得分:2)
应该是:
<%= Html.ActionLink("Users", "Index", new {Id=3})