我在 asp.net mvc 项目中定义了以下路由
//Products/Category/SubCategory/Page
routes.MapRoute(
"ProductCategoryTypePaging",
"Products/{Category}/{subCategory}/Page{page}",
new { controller = "Products", action = "Index" }, new { page = @"\d+" }
);
//Products/Category/Page
routes.MapRoute(
"ProductCategoryPaging",
"Products/{Category}/Page{page}",
new { controller = "Products", action = "Index" }, new { page = @"\d+" }
);
//Products/Category/SubCategory
routes.MapRoute(
"ProductCategoryType",
"Products/{Category}/{subCategory}",
new { controller = "Products", action = "Index", page = 1 }
);
//Products/Category
routes.MapRoute(
"ProductCategory",
"Products/{Category}",
new { controller = "Products", action = "Index" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
这些似乎工作正常,但如果我尝试查看产品详细信息,它就会中断。要查看详细信息,Url 是这样的:
/产品/详情/18
在 Products/Category/SubCategory 路线上运行匹配
我需要做些什么不同的事情来完成这项工作?