I use ASP.NET core Web application (web pages) .NET core version 2.1. In the razor page, I have a link to a specific div element on another site (in the same project), like so:
<a href="/MyAspPage#idOfDiv">Link</a>
However, the Intellisense complains (and rightfully so), that there is no /MyAspPage
in wwwroot
. After the build, this works just fine, because the link is valid of course.
Is there a way to use the asp-page
tag helper or any other tag helper to link to a hash anchor on another site? Such as (following does not work of course):
<a asp-page="/MyAspPage" asp-anchor="idOfDiv">Link</a>
Edit: What I want is a tag helper which would produce the exact link as above when I used the href
. The link is valid and works after build because the application takes care of it.
Are you looking for named anchors like this?
<a asp-controller="Foo" asp-action="Index" asp-fragment="bar">Features</a>
result:
https://localhost/Foo/Index#bar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.