我正在尝试为 a
创建自定义 ASP.NET Core 标签助手支持 asp-hash
的标签属性。该属性应该做的只是将提供的值附加到 href
的末尾。属性。
<a asp-controller="Home" asp-action="Index" asp-hash="mainDiv">some link</a>
然后会生成:
<a href="http://localhost/home/index#mainDiv">some link</a>
我找到了 AnchorTagHelper
的源代码在本节中 asp.net github repo但我找不到将内容附加到生成的 href
末尾的方法.
最佳答案
不存在asp-hash
属性,但无需制作自定义 anchor 标记助手。您正在寻找 asp-fragment
属性:
<a asp-controller="Home" asp-action="Index" asp-fragment="mainDiv">some link</a>
关于c# - 创建具有哈希字符串支持的自定义 anchor 标记助手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38620252/