当我调试它,产品和子类别链接工作正常,但类别显示我的名单,但当我点击其中之一,让我看看每个内的产品,不显示任何东西。ASP.NET MVC 5传统路由
这是我的ProductsController.cs。
public ActionResult Index(string category, string subcategory, string search, string sortBy, int? page){... }
对我有RouteConfig.cs:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "ProductsCreate",
url: "Products/Create",
defaults: new { controller = "Products", action = "Create" }
);
routes.MapRoute(
name: "ProductsbySubCategorybyPage",
url: "Products/{subcategory}/Page{page}",
defaults: new { controller = "Products", action = "Index" }
);
routes.MapRoute(
name: "ProductsbyCategorybyPage",
url: "Products/{category}/Page{page}",
defaults: new { controller = "Products", action = "Index" }
);
routes.MapRoute(
name: "ProductsbyPage",
url: "Products/Page{page}",
defaults: new { controller = "Products", action = "Index" }
);
routes.MapRoute(
name: "ProductsbySubCategory",
url: "Products/{subcategory}",
defaults: new { controller = "Products", action = "Index" }
);
routes.MapRoute(
name: "ProductsbyCategory",
url: "Products/{category}",
defaults: new { controller = "Products", action = "Index" }
);
routes.MapRoute(
name: "ProductsIndex",
url: "Products",
defaults: new { controller = "Products", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
您需要提供更多详细信息当Productsbycategory路由被激活时,显示的代码是什么/ view? (即,“当我点击其中一个...”时是不明确的) – jhenderson2099