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

1

9

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.. .

Monarski answered 8/10, 2010 at 1:22 Comment(0)
S
25

You explicitly call a route using

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

All the overloads for Html.RouteLink are here

Stalinism answered 13/1, 2011 at 17:39 Comment(2)
are you sure? the first parameter for RouteLink is the anchor text and the second is route name... so: Html.RouteLink("link_text", "route_name", route_parameters)Starshaped
Thank you for this answer. Why doesn't Microsoft provide a textual description of what the method does in their documentation? It gives all the overloads but the overloads of what? What does it do? Hopefully someone at MS reads this!Jobi

© 2022 - 2024 — McMap. All rights reserved.