15.6.2 Defining Optional URL Segments; Listinig 15-19. Specifying an Optional URL Segment in the RouteConfig.cs File

chap15
Jason Zhu 2021-11-24 18:37:05 +11:00
parent b1390aba96
commit e43c56e68a
1 changed files with 1 additions and 1 deletions

View File

@ -12,7 +12,7 @@ namespace UrlsAndRoutes
public static void RegisterRoutes(RouteCollection routes) public static void RegisterRoutes(RouteCollection routes)
{ {
routes.MapRoute("MyRoute", "{controller}/{action}/{id}", routes.MapRoute("MyRoute", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "DefaultId" }); new { controller = "Home", action = "Index", id = UrlParameter.Optional});
} }
} }
} }