1
我的网站目前设置了以下路线路由:MVC3用一个可选的第一个参数
routes.MapRoute(
"BrandList",
"Brands",
new { controller = "Brand", action = "Index" }
);
routes.MapRoute(
"BrandProducts",
"{brand}/Products",
new { controller = "Brand", action = "Products", manufacturer = "" },
new { manufacturer = new BrandConstraint() }
);
routes.MapRoute(
"Product",
"{brand}/{partNumber}",
new { controller = "Product", action = "Details", brand = "" },
new { manufacturer = new BrandConstraint() }
);
由此产生的URL像
http://oursite/Brands -> List of all brands
http://oursite/SomeBrand -> List of one brand's products
http://oursite/SomeBrand/ProductA -> Details for product
我刚刚得到了指令,但是,我们现在需要提供相同的页面
http://oursite/Brands -> List of all brands
http://oursite/SomeBrand -> List of one brand's products
http://oursite/Brands/SomeBrand -> List of one brand's products
http://oursite/SomeBrand/ProductA -> Details for product
http://oursite/Brands/SomeBrand/ProductA -> Details for product
我知道我可以创建两个路由,与当前的相同和Product
路线,并在开始处增加“Brands /”。如果需要的话,我会这样做,但我更愿意不必重复每个路由条目(这不仅仅是这两个)。
任何人都有建议吗?