From c4f05470abf26d8394801fc8adeeb597951c7760 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Tue, 23 Nov 2021 20:42:13 +1100 Subject: [PATCH] 15.5 Using Static URL Segments; Listing 15-14. Aliasing a Controller and an Action in the RouteConfig.cs File --- UrlsAndRoutes/UrlsAndRoutes.Tests/RouteTests.cs | 1 + UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/UrlsAndRoutes/UrlsAndRoutes.Tests/RouteTests.cs b/UrlsAndRoutes/UrlsAndRoutes.Tests/RouteTests.cs index f46d0ea..097e115 100644 --- a/UrlsAndRoutes/UrlsAndRoutes.Tests/RouteTests.cs +++ b/UrlsAndRoutes/UrlsAndRoutes.Tests/RouteTests.cs @@ -103,6 +103,7 @@ namespace UrlsAndRoutes.Tests TestRouteMatch("~/Customer", "Customer", "Index"); TestRouteMatch("~/Customer/List", "Customer", "List"); TestRouteFail("~/Customer/List/All"); + TestRouteMatch("~/Shop/Index", "Home", "Index"); } } } diff --git a/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs b/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs index 4b2a14a..c461097 100644 --- a/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs +++ b/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs @@ -11,6 +11,9 @@ namespace UrlsAndRoutes { public static void RegisterRoutes(RouteCollection routes) { + routes.MapRoute("ShopSchema2", "Shop/OldAction", + new { controller = "Home", action = "Index" }); + routes.MapRoute("ShopSchema", "Shop/{action}", new { controller = "Home" });