Is there a reason you can't just use the following with the built-in route handler:
routes.MapRoute("LocationRoute",
"{countryname}/{statename}/{cityname}",
new { controller = "Location", action = "GetLocations" });
That may conflict with the default "{controller}/{action}/{id}" route, but that would happen with your current system anyway (unless you make a custom Route, inheriting from System.Web.Routing.RouteBase
, rather than a custom Route Handler). The Route Handler is for handling what to do AFTER the route data has been extracted. Since you're still using Controller and Action, you should still be able to use the MvcRouteHandler
. If you want to customize how the Route Data is extracted, you probably want a custom Route.
Btw, if you want to use a route which doesn't involve Controller and Action names, use Html.RouteLink
. ActionLink
is just a wrapper which puts the controller and action into the RouteValuesDictionary
and calls the same internal helper as RouteLink
.
Although in this case, the route still has a Controller and Action ("Location" and "GetLocations"), so you can still use ActionLink
. I think ActionLink
lets you specify a Route Name, so if you give your route a name you can specify that name in ActionLink
and it will use that route to generate the URL (I may be wrong about that and if so you can still use RouteLink
and manually add the controller and action route values)