Хабр Курсы для всех
РЕКЛАМА
Большая витрина: от крупнейших школ до частных авторов. Сравнивайте по цене, длительности, формату и выбирайте самый подходящий курс!
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