@Html.ActionLink generates anchor <a> tag or hyperlink on a view page in MVC whereas
@Url.Action returns only a qualified URL.
HTML.Actionlink()
:
HTMLHelper (@Html) object uses
ActionLink() method to render the anchor HTML element with specified link text
and action /controller name.
Here is an example of HTML.ActionLink() method to generate a hyperlink with action/controller name:
@Html.ActionLink("Home", "Home", "Person")
It Generates <a
href="/Person/Home" >Home</a>
@Html.ActionLink("Product", "Detail", "Product", new { id ="5668"}, null)
It Generates: < a
href="https://www.blogger.com/product/detail/5678" > Product
</a>
URL.Action
():
URL.Action method is used to generate the
qualified URL by using the action and controller name with routes value.
Here is an example of URL.Action() method:
Url.Action("detail",
"product", new { id = "5678" })
It Generates: /product/detail/5678
No comments:
Post a Comment