What is the difference between Html.ActionLink and Html.RouteLink ?

The question arose due to the fact that I read it, saying that supposedly Html.RouteLink helps to choose a specific route from a set of routes when generating a link. However, I still do not understand how to do this, and in general Html.ActionLink and so selects the route that matches the signature. Then what is the meaning of Html.RouteLink do not understand. Tell me please.

Here is the code, why two links lead to the same controller and action if different routes are specified

 routes.MapRoute( name: "D1", url: "{controller}/{action}", defaults: new { controller = "Home", action = "Index" } ); routes.MapRoute( name: "D2", url: "{controller}/{action}/{id}", defaults: new { controller = "Zurab", action = "Pavel" } ); 

Links

 @Html.RouteLink("Click", "D2", new { id = 14 }) @Html.ActionLink("Click", "Index") 

    1 answer 1

    The ActionLink method takes the name of the controller and action and uses these parameters to search for a suitable element in the routing table. At the same time, the first entry that satisfies the search conditions (controller and action match) is considered appropriate. Accordingly, if the application has complex routing, then ActionLink may work longer than RouteLink. Changing the routing table (and even changing the order of entries) can disrupt the work of previously written ActionLink calls.

    The RouteLink method uses the name of the route object to search the table. Accordingly, the order of adding entries to the routing table does not matter, and changing / adding routes will not disrupt RouteLink. Also, RouteLink provides greater accuracy in choosing a route, which is especially useful when ActionLink can cause some ambiguity. For example, there may be several routes for one controller and action. Then ActionLink will always return the first route, and using RouteLink, you can specify a specific route.