From e43c56e68a033d1ba748e9d809382efbcd54f601 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Wed, 24 Nov 2021 18:37:05 +1100 Subject: [PATCH] 15.6.2 Defining Optional URL Segments; Listinig 15-19. Specifying an Optional URL Segment in the RouteConfig.cs File --- UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs b/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs index cae7fce..6fe3aa0 100644 --- a/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs +++ b/UrlsAndRoutes/UrlsAndRoutes/App_Start/RouteConfig.cs @@ -12,7 +12,7 @@ namespace UrlsAndRoutes public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute("MyRoute", "{controller}/{action}/{id}", - new { controller = "Home", action = "Index", id = "DefaultId" }); + new { controller = "Home", action = "Index", id = UrlParameter.Optional}); } } }