0
routes.MapRoute(
"Items", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Item", action = "Index", id = UrlParameter.Optional} // Parameter defaults
);
爲HtmlHelper:
@Html.ActionLink("Chairs", "List", "Item", new {id="Chairs"}, null)
它生成的鏈接:
http://localhost:57899/Item/List?id=Chairs
我想什麼它顯示:
http://localhost:57899/Item/List/Chairs
如何做到這一點?
'ItemController'的'List'動作有什麼特徵? –
@David Signature?'public ActionResult List(string id) { return View(_repository.GetItems(id)); }' –