0

这是我的路线配置的一部分:

        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的路线,以便在此之前与路线不匹配的所有内容都转到控制器 Home 和操作 Index ?

4

1 回答 1

1
routes.MapRoute(
"spa",
"{*path}",
new { controller = "Home", action = "Index"});
于 2013-10-31T08:55:09.770 回答