Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
I am trying to declare an import map in my web application. So in _Layout.cshtml
I will write something like:
<script type="importmap">
{
"imports": {
"my-module": "@Url.Content("~/path/to/my/module.js")"
}
}
</script>
However, this does not get the benefits of asp-append-version
, and the way to achieve the same result as asp-append-version
is not obvious.
Describe the solution you'd like
Currently, the ImageTagHelper
, LinkTagHelper
, and ScriptTagHelper
all privately re-implement this same method:
aspnetcore/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs
Lines 140 to 158 in d05f358
aspnetcore/src/Mvc/Mvc.TagHelpers/src/LinkTagHelper.cs
Lines 532 to 551 in d05f358
aspnetcore/src/Mvc/Mvc.TagHelpers/src/ScriptTagHelper.cs
Lines 412 to 430 in d05f358
I think these should be deduplicated into a single implementation. Perhaps UrlHelper
itself could contain this bit of logic and expose it via UrlHelper.Content(contentPath, appendVersion)
, or perhaps it would be better encapsulated by some new service type which could then also be used by UrlHelper.Content(contentPath, appendVersion)
.
Either way, I would really like to see UrlHelper.Content(contentPath, appendVersion)
.
Additional context
No response