Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
routes.MapRoute("YourHelloWorldRoute", "helloworld", new { controller = "Home", action = "Index" })routes.MapRoute(
"helloworld",
"helloworld",
new { controller = "hello", action = "world" }
);
routes.MapRoute(
"foobar",
"foobar",
new { controller = "foo", action = "bar" }
);
//...ваши 50 правил
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Default", action = "Index", id = UrlParameter.Optional }
)
routes.MapRoute(
"helloworld",
"helloworld",
new { controller = "hello", action = "world" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Default", action = "Index", id = UrlParameter.Optional }
)
/*
* имеем два урла для одного действия:
* /helloworld
* /hello/world
*/
Hmm, I'm starting to think this might be true — debugging through the code, it looks like RouteTable.Routes.Add() successfully increases the number of routes, but apparently only for that Request cycle. It doesn't seem to persist it to the RouteTable that's used throughout the app.
«Классические» friendly url в ASP.NET MVC