2

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.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Ahsan
  • 271
  • 1
  • 8
  • 16

1 Answers1

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