What is the difference between RouteLink and ActionLink in ASP.NET MVC ?

Published on March 29, 2013 by abundantcode

Filed under ASP.NET

Last modified March 29, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 5507 times

This article will cover some of the key differences between the RouteLink and ActionLink helper methods in ASP.NET MVC.

What is the difference between RouteLink and ActionLink in ASP.NET MVC ?

The Html.ActionLink renders the hyperlink tag to the specified controller action which uses the Routing API internally to generate URL.

@Html.ActionLink("Abundant Code on C# and Java Samples", "ActionName","ControllerName")

This renders the Anchor tag that links to the action method.

The ActionLink method renders an element that links to an action method.

The Html.RouteLink is similar to the ActionLink but accepts a parameter for route name and does not include the parameters for Controller name and action name.

Eg : @Html.RouteLink("Abundant Code on C# and Java Samples", new { action= "ActionName"})

The RouteLink method renders an element that links to a URL, which can resolve to an action method, a file, a folder, or some other resource.

RouteLink generates the URL to a specific route identified by the route values.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

1 Comment

  1. Interesting .NET Links – March 29 , 2013 | TechBlog
    March 29, 2013 - 11:37 pm

Leave a Comment


x

You might be Interested in these Posts

How to return Json instead of XML in ASP.NET Web API ?

When you make a call to the ASP.NET Web API action method and notice this in Google Chrome browser ,...

How to Add Web API to existing ASP.NET Web Forms Project ?

In one of the previous posts , we saw how to add the WebAPI to the existing ASP.NET MVC project. Wel...

How to Add Web API to existing ASP.NET MVC Project ?

There are times when you might want to add Web API project to one of your existing ASP.NET MVC proje...