15.5 Using Static URL Segments; Listing 15-14. Aliasing a Controller and an Action in the RouteConfig.cs File

chap15
Jason Zhu 2021-11-23 20:42:13 +11:00
parent 7e57cd2d16
commit c4f05470ab
2 changed files with 4 additions and 0 deletions

View File

@ -103,6 +103,7 @@ namespace UrlsAndRoutes.Tests
TestRouteMatch("~/Customer", "Customer", "Index"); TestRouteMatch("~/Customer", "Customer", "Index");
TestRouteMatch("~/Customer/List", "Customer", "List"); TestRouteMatch("~/Customer/List", "Customer", "List");
TestRouteFail("~/Customer/List/All"); TestRouteFail("~/Customer/List/All");
TestRouteMatch("~/Shop/Index", "Home", "Index");
} }
} }
} }

View File

@ -11,6 +11,9 @@ namespace UrlsAndRoutes
{ {
public static void RegisterRoutes(RouteCollection routes) public static void RegisterRoutes(RouteCollection routes)
{ {
routes.MapRoute("ShopSchema2", "Shop/OldAction",
new { controller = "Home", action = "Index" });
routes.MapRoute("ShopSchema", "Shop/{action}", routes.MapRoute("ShopSchema", "Shop/{action}",
new { controller = "Home" }); new { controller = "Home" });