Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.ActionLink() vs. <a> tag

Tags:

asp.net-mvc

In ASP.NET MVC, for linking standard pages (the ones that does not need special parameters or query string), is there any situation where I should prefer Html.ActionLink() to a standard <a href="#">Link</a> tag?

Thanks.

like image 229
abenci Avatar asked May 20 '26 03:05

abenci


1 Answers

@Html.ActionLink is tied into the MVC routing definitions. It isn't just a helper for writing an anchor tag, it uses routing to determine what the href looks like and how it's structured.

By using ActionLink you insure all your links are rendered based on how your MVC routes are configured.

Routing is powerful and can prevent the need of having to have lots of query string variables or hidden fields to pass around data.

Use @Html.ActionLink, in the end the extra effort is negligible.

like image 112
Honorable Chow Avatar answered May 24 '26 17:05

Honorable Chow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!