我在Html方面有问题.当我有一条包含多个参数的路由时,使用ActionLink.例如,考虑到我的全球计划中定义的以下路由.asax文件:
routes.MapRoute(
"Default", // Route name
"{controller}.mvc/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute(
"Tagging",
"{controller}.mvc/{action}/{tags}",
new { controller = "Products", action = "Index", tags = "" }
);
routes.MapRoute(
"SlugsAfterId",
"{controller}.mvc/{action}/{id}/{slug}",
new { controller = "Products", action = "Browse", id = "", slug = "" }
);
前两条路由运行正常,但当我try 使用以下方法创建指向第三条路由的操作链接时:
<%= Html.ActionLink(Html.Encode(product.Name), "Details", new { id = product.ProductId, slug = Html.Encode(product.Name) }) %>
我最终得到一个类似[site-root]/Details/1?slug=url-slug的URL,而我希望URL更像[site-root]/Details/1/url-slug
有人能看出我错在哪里吗?