In this chapter, you will learn:
- What is
Html.ActionLinkhelper method in ASP.NET MVC5? - 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>
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.