1
0
mirror of https://github.com/rudollee/LearningMVC.git synced 2026-08-11 16:32:55 +00:00

Ch. 16 Routing Adv (until 16-5)

This commit is contained in:
wook
2017-04-11 00:47:48 +09:00
parent f219a8df27
commit 2fea7ffb5e
9 changed files with 79 additions and 42 deletions
+12 -5
View File
@@ -63,11 +63,18 @@ namespace UrlsAndRoutes
// new { controller = "^H.*", action = "^Index|About", httpMethod = new HttpMethodConstraint("GET"), id = new RangeRouteConstraint(10, 20) },
// new[] { "URLsAndROutes.Controllers" });
routes.MapRoute("MyRoute", "{controller}/{action}/{id}/{*catchall}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new { controller = "^H.*", action = "^Index|About", httpMethod = new HttpMethodConstraint("GET"),
id = new CompoundRouteConstraint(new IRouteConstraint[] { new AlphaRouteConstraint(), new MinLengthRouteConstraint(6) }) },
new[] { "URLsAndROutes.Controllers" });
//routes.MapRoute("MyRoute", "{controller}/{action}/{id}/{*catchall}",
// new { controller = "Home", action = "Index", id = UrlParameter.Optional },
// new { controller = "^H.*", action = "^Index|About", httpMethod = new HttpMethodConstraint("GET"),
// id = new CompoundRouteConstraint(new IRouteConstraint[] { new AlphaRouteConstraint(), new MinLengthRouteConstraint(6) }) },
// new[] { "URLsAndROutes.Controllers" });
routes.MapMvcAttributeRoutes();
routes.MapRoute("NewRoute", "App/Do{action}", new { controller = "Home" });
routes.MapRoute("MyRoute", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
}
}