VSG24 VSG24 - 1 year ago 147
ASP.NET (C#) Question

Creating a custom anchor tag helper with hash string support

I'm trying to create a custom ASP.NET Core tag helper for

tag that supports
attribute. What that attribute is supposed to do is just append the provided value to the end of the

<a asp-controller="Home" asp-action="Index" asp-hash="mainDiv">some link</a>

would then generate:

<a href="http://localhost/home/index#mainDiv">some link</a>

I found the source code for
in this section in asp.net github repo but I can't find a way to append stuff to the end of generated

tmg tmg
Answer Source

No asp-hash attribute exists, but there is no need to make a custom anchor tag helper. You are looking for asp-fragment attribute:

<a asp-controller="Home" asp-action="Index" asp-fragment="mainDiv">some link</a>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download