4
我定義爲路線的一串:html.routelink不走指定路線
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,以便請求應該轉到默認路由。