我有一個沒有約束的自定義路由,它會生成一個帶有ActionLink的Restful URL。MVC ActionLink在添加約束之後生成NON-Restul URL
路線 -
routes.MapRoute(
"Blog", // Route name
"Blog/{d}/{m}/{y}", // URL with parameters,
new { controller = "Blog", action = "Retrieve" }
生成 -
http://localhost:2875/Blog/12/1/2010
從 -
<%=Html.ActionLink("Blog Entry - 12/01/2010", "Retrieve", "Blog", new { d = 12, m = 01, y = 2010 }, null)%>
如果我添加的約束,像這樣。
routes.MapRoute(
"Blog", // Route name
"Blog/{d}/{m}/{y}", // URL with parameters,
new { controller = "Blog", action = "Retrieve" },
new { d = @"\d{2}", m = @"\d{2}", y = @"\d{4}" }
它產生 -
http://localhost:2875/Blog/Retrieve?d=12&m=1&y=2010
額外的信息:它是在自定義路由前加入。
任何想法? 乾杯