我有一堆已定义的路由:
routes.MapRoute(
name: "ID",
url: "{category}/{subcategory}/{lowercategory}/{lowercategory1}/{id}/{ignore}",
defaults: new { controller = "Home", action = "Index", ignore = UrlParameter.Optional }
);
routes.MapRoute(
name: "LowerCategory1",
url: "{category}/{subcategory}/{lowercategory}/{lowercategory1}",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapRoute(
name: "LowerCategory",
url: "{category}/{subcategory}/{lowercategory}",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapRoute(
name: "Subcategory",
url: "{category}/{subcategory}",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapRoute(
name: "Category",
url: "{category}",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
现在我使用routeLink来访问默认路由,但它不起作用。
@Html.RouteLink("Create Ad", "Default", new { controller="Electronics",action="Details" })
请求发送到主页控制器的索引函数。我做错了什么?如何使用routeLink,使请求应该转到默认路由。