Html.ActionLink Complete Example in ASP.Net MVC 5

In this chapter, you will learn:
  1. What is Html.ActionLink helper method in ASP.NET MVC5?
  2. Programming Example

Html.ActionLink is used for creating hyperlink. This action method renders hyperlink in html pages but it redirect to action method not directly to view pages.

Programming Example

@using HtmlHelperDemo.Models
@model UserModel

<h1>Html.ActionLink Example</h1>

<!-- Redirect in Same Controller -->
@Html.ActionLink("Contact Page","Contact")

<br />

<!-- Redirect in Another Controller -->
@Html.ActionLink("Report Page","Index","Report")

Output

Html Output
<!-- Redirect in Same Controller -->
<a href="/Home/Contact">Contact Page</a>

<br />

<!-- Redirect in Another Controller -->
<a href="/Report">Report Page</a> 

Html.ActionLink

Summary

As you seen that Html.ActionLink is used for rendering hyperlink in html. It doesn't point to view page directly instead of it points to action method. In the next chapter, you will learn Html.RouteLink in ASP.Net MVC 5.

More Articles

 

Share your thought



PLEASE DISABLE ADBLOCKER AND SUPPORT US!

Please support us by enabling ads on this page. Refresh

YOU DON'T LIKE ADS, WE ALSO DON'T LIKE ADS!
 
But we have to show ads on our site to keep it free and updated. We have to pay huge server costs, domain costs, CDN Costs, Developer Costs, Electricity and Internet Bill. Your little contribution will encourage us to regularly update this site.