我有一条使用我的通配符的路线:
[Route("{category}/{subcategory?}/{property?}")]
public ActionResult SubPage(string category, string subcategory, string property, int? type)
{}
问题是我想在" Amp"下添加另一个控制器。夹
[Route("amp/{category}/{subcategory?}/{property?}")]
public ActionResult Amp(string category, string subcategory, string subSubCategory)
{}
我的路由器看起来像这样:
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Amp",
url: "amp/{controller}/{action}/{id}",
defaults: new { controller = "Amp", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
如果网址为/ amp / category1,则这不起作用,因为网址结构与网址匹配