Html.ActionLink as a button or an image, not a link

I like to use Url.Action() and Url.Content() like this:

<a href="https://stackoverflow.com/questions/596444/@Url.Action("MyAction", "MyController")">
    <img src="@Url.Content("~/Content/Images/MyLinkImage.png")" />
</a>

Strictly speaking, the Url.Content is only needed for pathing is not really part of the answer to your question.

Thanks to @BrianLegg for pointing out that this should use the new Razor view syntax. Example has been updated accordingly.

Leave a Comment