aspnetcore: Error when loading test.html using MapStaticAssets: Failed to load resource: net::ERR_CONTENT_DECODING_FAILED
Repro steps:
- Create an empty ASP.NET Core app
- Add
app.MapStaticAssets() - Add wwwroot/test.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
Run the app and browser to /test.html
Expected result: test.html renders in the browser
Actual result: Failed to load resource: net::ERR_CONTENT_DECODING_FAILED
Workarounds:
- Swap
app.MapStaticAssets()forapp.UseStaticFiles() - Use a .json file instead of a .html file
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 14
- Comments: 21 (7 by maintainers)
This is a pain.
I have found that the presence of a
<body>tag within the html file somehow breaks the serving of the file.OK:
Broken:
Hope this helps.
In lauchSettings.json
Anyway, it seems the issue is due to gzip compression of static assets collides with browser link. You can stop hot reload by adding the following line in launchSettings.json “hotReloadEnabled”: false
"https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "applicationUrl": "https://localhost:5032", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, "hotReloadEnabled": false },@javiercn Will we be fixing this in a patch?