0
我有一個看起來像這樣的路線:asp.net的MVC出局路由
new { controller = "ControllerName", action = "PhotoGallery", slug = "photo-gallery", filtertype = UrlParameter.Optional, filtervalue = UrlParameter.Optional, sku = UrlParameter.Optional}
,我有一個看起來像這樣的形式:
<%using(Html.BeginForm("PhotoGallery", "ControllerName", FormMethod.Get)) {%>
<%:Html.Hidden("filtertype", "1")%>
<%:Html.DropDownList("filtervalue", ViewData["Designers"] as SelectList, "Photos by designer", new { onchange = "selectJump(this)" })%>
<%}%>
現在時表單提交我得到的表單值作爲查詢字符串附加到url(?filtertype = 1等)有沒有辦法讓這個表單使用路由來呈現URL?
所以形式會後,看起來像這樣的URL:
www.site.com/photo-gallery/1/selectedvalue
,而不是像」
www.site.com/photo-gallery?filtertype=1&filtervalue=selectedvalue
感謝
感謝您的答覆!我最終使用PRG模式來獲得我需要的效果。我的路由很複雜,不允許有這樣的一般規則。 – Paul 2010-09-18 15:31:50