我想要基于部门名称和产品名称的自定义路由。例如 /mobiles/nokia-6303
当我调用产品页面时,它工作正常。当我在默认情况下调用其他产品页面(如主页)时,遵循控制器和操作方法正在执行
defaults: new { controller = "ContentPage", action = "ProductDetail" }
如何避免这个问题?
routes.MapRoute(
name: "ProductDetailsPage",
url: "/{DepartmentName}/{ProductName}",
defaults: new { controller = "ContentPage", action = "ProductDetail" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index" }
);
提前感谢拉杰什