Displaying URL’s in ASP.NET MVC 3 - Difference between Html.ActionLink vs Url.Action

The Html.ActionLink method renders a hyperlink (<a href=".."></a>) to another controller action. The Url.Action URL helper works the same way as Html.ActionLink, but it does not return an anchor tag.

Let’s see an example. Add the following code to your Index.cshtml or any view you want to display this on


Run the page and observe the source generated


While Html.ActionLink generates an anchor tag, Url.Action on the other hand generates just the URL. Generating just the URL could be helpful in scenarios where you want a convenient way to generate HTML for a link manually.

Note: For security purpose, make sure to encode your URL using Url.Encode or Html.AttributeEncode:



About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.


Stuart Ben said...

Thanks for sharing this! I wish there would be more info about that:)

Anonymous said...

Hey is there any way to get this to work in a chrome browser?