以下是我的路线配置的一部分:
routes.MapHttpRoute(
name: ApiControllerActionAndId,
routeTemplate: "api/{controller}/{action}/{id}",
defaults: null, //defaults: new { id = RouteParameter.Optional } //,
constraints: new { id = @"^\d+$" }
);
routes.MapRoute(
"Account",
url: "Account/{action}/{id}",
defaults: new { controller = "Account", id = UrlParameter.Optional }
);
routes.MapRoute(
"spa",
"{section}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new { section = @"home|questions|admin" });
“spa”路线是列表中的最后一条路线。
有没有办法让我可以更改名为spa的最后一条路线,以便所有与路由不匹配之前进入控制器主页和动作索引?
答案 0 :(得分:1)
routes.MapRoute(
"spa",
"{*path}",
new { controller = "Home", action = "Index"});