Is there any difference between HTML.ActionLink vs Url.Action or they are just two ways of doing the same thing?
When should I prefer one over the other?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, there is a difference.
Html.ActionLinkgenerates an<a href=".."></a>tag whereasUrl.Actionreturns only an url.For example:
generates:
and
Url.Action("someaction", "somecontroller", new { id = "123" })generates:There is also Html.Action which executes a child controller action.