How do I attach an element to an ASP.NET MVC link while keeping a virtual path?

@Html.ActionLink(@ProjectName, "Index", "Home") 

Those. This method will check the settings of the routers and return a valid path, even if the routing scheme changes, unlike <a href="/Home/Index/">... </a>

Desired result: <a href="/Home/Index" .... > Text <i>..</i></a>

Tried: <a href="@Url.Content("/Home/Index") ...">Text<i>...</i></a> - returns the desired result, but it seems to me that this is not quite right.

Tell me how to do it right.

1 answer 1

Use @Url.Action :

 <a href="@Url.Action("Index", "Home")" ...>Text<i>...</i></a>