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.. .
Html. ActionLink creates a hyperlink on a view page and the user clicks it to navigate to a new URL. It does not link to a view directly, rather it links to a controller's action.
The value will only be added as query string values if its FormMethod. Get (and you can remove the route values from the BeginForm() method). But what is the point of this - they are hidden inputs, not editable values.
Routing in ASP.NET MVC cs file in App_Start Folder, You can define Routes in that file, By default route is: Home controller - Index Method. routes. MapRoute has attributes like name, url and defaults like controller name, action and id (optional).
You explicitly call a route using
<%: Html.RouteLink("link_text", "route_name", route_parameters) %>
All the overloads for Html.RouteLink are here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With