asp.net mvc 3.0 routing问题
比如我定制了两个路由
routes.MapRoute(
"Products", // Route name
"Product/{action}/{p1}/{p2}/{p3}", // URL with parameters
new { controller = "Product", action = "Index", p1 = UrlParameter.Optional,p2 = UrlParameter.Optional,p3 = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Product", // Route name
"Product/{action}/{p1}", // URL with parameters
new { controller = "Product", action = "Index", p1 = UrlParameter.Optional } // Parameter defaults
);
Controller 里
[HttpGet]
public ActionResult Index(string p1 ,string p2, string p3)
{
string d = p1 + p2 + p3;
return View();
}
[HttpGet]
public ActionResult Index(string p1)
{
string d = p1;
return View();
}
这样写会报错,就是不能存在action一样的 同时上面的filter也一样的。。。
另外参数还必须跟Routing里定制的一个样。。。
那如果我既有 /product/index/3 又有这样 product/index/1/2/3 这样的问题怎么解决呢??