这是 浏览器里的地址 http://localhost:6037/Procducts/SingOrder?ordernumber=2011%2F7%2F14%2015%3A56%3A43
我想网址变成这样的 http://localhost:6037/Procducts/SingOrder/2011-07-14 2014:34:19
路由该怎么配置。。。。
routes.MapRoute( "Default", // 路由名称
"{controller}/{action}/{id}", // 带有参数的 URL
new { controller = "Procducts", action = "Index", id = UrlParameter.Optional } // 参数默认值 );
routes.MapRoute("SingOrder",
"Procducts/SingOrder/{pnumberid}",
new { controller = "Procducts", action = "SingOrder" },
new { date=@"[\s\S]+"});
routes.MapRoute("BlogActive",
"Procducts/IsInShopingCar/{pid}/{num}",
new { controller = "Procducts", action = "IsInShopingCar" },
new { date = @"\d{0,}" });
这是我现在的路由规则。
routes.MapRoute(
"Procducts-SingOrder",
"Procducts/SingOrder/{ordernumber}",
new { controller = "Procducts", action = "SingOrder" }
);
其实也没必要再重写了 你把你的那个http://localhost:6037/Procducts/SingOrder/2011-07-14 2014:34:19 规则路由定义为一代个路由 就可以了 路由是从上到下解析的 第一个路由匹配你的规则 就不会继续往下再解析了