How to call the Route Name in Html.ActionLink asp.net MVC?

idontknowhow picture idontknowhow · Oct 8, 2010 · Viewed 10.5k times · Source

I have this route

routes.MapRoute(
    "ViewGames",     // Route name
    "psp/{controller}/{action}",                           // URL with parameters
    new { controller = "Games"}  // Parameter defaults
);

and I used <%= Html.ActionLink("God of War", "godofwar", "Games")%> all though it gives me a link like this somesite.com/psp/games/godofwar/ but the other link became also like that for example my homecontroller became this somesite.com/psp/home/about/?

how can call the routename so other won't have the ViewGames route?

I dont want to try this <a href="/psp/games/godofwar/"> which is not good.. .

Answer

Felix Martinez picture Felix Martinez · Jan 13, 2011

You explicitly call a route using

<%: Html.RouteLink("link_text", "route_name", route_parameters) %>

All the overloads for Html.RouteLink are here