I want to obsolete controller name from Html.ActionLink
because I defined my controller in route how to do this,
because if I leave controller name blank in Html.ActionLink
mvc3 automatically put current controller name in Action Link.
Asked
Active
Viewed 814 times
2

Luke Girvin
- 13,221
- 9
- 64
- 84

Ahsan
- 271
- 1
- 8
- 16
-
2What do you mean by "i want to obsolete controller name from Html.ActionLink" – dtsg May 22 '12 at 08:22
-
I think OP doesn't want to specify the controller twice, both on the route and the action link. – Marnix van Valen May 22 '12 at 08:50
1 Answers
3
If you named your route, you can use RouteLink
instead of ActionLink
.
You'll only have to specify the name of the route, not the controller.
Here's an example of a named route:
routes.MapRoute( "myRoute",
"doStuff/Now",
new {controller = "MyController", action = "DoIt"} );
And here's how to use it in your view
Html.RouteLink( "Do it!", "myRoute" );
Please see MSDN for full details on RouteLink.

Marnix van Valen
- 13,265
- 4
- 47
- 74