Is there an existing issue for this?
Describe the bug
In an ASP.NET Core MVC project using MapStaticAssets() with WithStaticAssets(), the JavaScript file referenced via <script type="module" src="..."> is fetched twice when:
- The application has been published, and
- The page is loaded for the first time, or the browser cache is disabled, or a hard reload (Ctrl+F5) is performed
In development, the issue does not occur regardless of cache state.
Modules imported transitively from the entry script (via import statements inside JS) are fetched only once. The duplicate is specifically on the script directly referenced by the src attribute on a <script type="module"> tag.
I am not sure whether this is a bug or intentional behavior. Either way, clarification or documentation would be appreciated, since the workaround (inline import statement) is non-obvious and the bandwidth cost is real on cold loads.
Expected Behavior
<script type="module" src="..."> should result in a single network request, matching the behavior of:
- The same setup in development
- Modules imported via
import statements
- Non-module scripts (
<script>, <script defer>)
Steps To Reproduce
dotnet new mvc -n ImportMapRepro
- Configure
Program.cs:
app.MapStaticAssets();
// NOTE: WithStaticAssets() does not work with MapControllerRoute()
// (see #59003), so MapControllers + MapDefaultControllerRoute is used instead.
app.MapControllers().WithStaticAssets();
app.MapDefaultControllerRoute();
- Add
wwwroot/js/dependency.js:
- Add
wwwroot/js/entry.js:
import { value } from './dependency.js';
console.log(value);
- In
_Layout.cshtml's <head>:
<base href="~/" />
<script type="importmap"></script>
- In
_Layout.cshtml's <body>:
<script type="module" src="~/js/entry.js"></script>
- Publish the app and run it from the publish output.
- Open the app, DevTools → Network → enable "Disable cache" → reload.
Result:
- entry.{hash}.js appears twice (HTTP 200, same URL, same ETag)
- dependency.{hash}.js appears once
Exceptions (if any)
None
.NET Version
.NET 10 (also reproducible on .NET 9)
Anything else?
Observations narrowing down the trigger
The duplicate occurs only when all of the following are true:
- The application has been published (not development)
- A
<script type="importmap"></script> tag is rendered in the layout
- The script is loaded via
<script type="module" src="...">
Changing any one eliminates the duplicate:
- Removing the importmap tag → single fetch (but disables JS module fingerprinting)
- Loading the entry via inline
import instead of src -> single fetch:
<script type="module">
import "/js/entry.js";
</script>
- Using a non-module <script src="..."> → single fetch
Difference between dev and publish importmaps
In development the rendered importmap contains only the imports field. After publish it also contains an integrity field with hashes for each asset. This is the most visible difference between the two modes; whether it relates to the issue is unclear.
Network tab screenshot

The entry module loaded via <script type="module" src> is fetched twice (red box). The dependency imported from inside that entry is fetched once (red underline).
For a page loading 10–20 module scripts, the cold load and Ctrl+F5 cost is doubled. There is no clear reason why a module script loaded via src should be fetched differently from one loaded via import. If this is intentional, it would help to document it — the workaround is not discoverable.
Note: This issue was drafted with assistance from an AI assistant based on observations from my own testing. The reproduction steps and behavior described have been verified by me.
Is there an existing issue for this?
Describe the bug
In an ASP.NET Core MVC project using
MapStaticAssets()withWithStaticAssets(), the JavaScript file referenced via<script type="module" src="...">is fetched twice when:In development, the issue does not occur regardless of cache state.
Modules imported transitively from the entry script (via
importstatements inside JS) are fetched only once. The duplicate is specifically on the script directly referenced by thesrcattribute on a<script type="module">tag.I am not sure whether this is a bug or intentional behavior. Either way, clarification or documentation would be appreciated, since the workaround (inline
importstatement) is non-obvious and the bandwidth cost is real on cold loads.Expected Behavior
<script type="module" src="...">should result in a single network request, matching the behavior of:importstatements<script>,<script defer>)Steps To Reproduce
dotnet new mvc -n ImportMapReproProgram.cs:wwwroot/js/dependency.js:wwwroot/js/entry.js:_Layout.cshtml's<head>:_Layout.cshtml's<body>:Result:
Exceptions (if any)
None
.NET Version
.NET 10 (also reproducible on .NET 9)
Anything else?
Observations narrowing down the trigger
The duplicate occurs only when all of the following are true:
<script type="importmap"></script>tag is rendered in the layout<script type="module" src="...">Changing any one eliminates the duplicate:
importinstead ofsrc-> single fetch:Difference between dev and publish importmaps
In development the rendered importmap contains only the
importsfield. After publish it also contains anintegrityfield with hashes for each asset. This is the most visible difference between the two modes; whether it relates to the issue is unclear.Network tab screenshot

For a page loading 10–20 module scripts, the cold load and Ctrl+F5 cost is doubled. There is no clear reason why a module script loaded via
srcshould be fetched differently from one loaded viaimport. If this is intentional, it would help to document it — the workaround is not discoverable.Note: This issue was drafted with assistance from an AI assistant based on observations from my own testing. The reproduction steps and behavior described have been verified by me.