喜歡的網址:ASP.NET MVC3自定義路由映射?
/query/test/p1s1c1
的動作是:
public ActionResult Test(int price = 1, int size = 1, int category = 1)
{
ViewBag.param = "price:" + price + "size:" + size + "category" + category;
return View();
}
我的路由映射是:
routes.MapRoute(
"Query", // Route name
"Query/test/p{price}s{size}c{category}",
new { controller = "Query", action = "Test", price = UrlParameter.Optional, size = UrlParameter.Optional, category = UrlParameter.Optional },
new { price = @"\d+", size = @"\d*" , category = @"\d*" } // Parameter defaults
);
,但它不能正常工作,誰可以幫幫我嗎?