`_framework/blazor-hotreload` 404 when running under subdirectory
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Please note: This is not the same as the 404 for blazor-hotreload.js
, which has been fixed with https://github.com/dotnet/aspnetcore/pull/36897, but this is the second part of https://github.com/dotnet/aspnetcore/issues/35555 which I believe was missed.
The fetch request for _framework/blazor-hotreload
from blazor-hotreload.js
returns 404 due to the url being relative to the subdirectory, contents of blazor-hotreload.js
:
export function receiveHotReload() {
return BINDING.js_to_mono_obj(new Promise((resolve) => receiveHotReloadAsync().then(resolve(0))));
}
async function receiveHotReloadAsync() {
const cache = window.sessionStorage.getItem('blazor-webassembly-cache');
let headers;
if (cache) {
headers = { 'if-none-match' : cache.etag };
}
const response = await fetch('_framework/blazor-hotreload', { headers });
if (response.status === 200) {
const deltas = await response.json();
if (deltas) {
try {
deltas.forEach(d => window.Blazor._internal.applyHotReload(d.moduleId, d.metadataDelta, d.ilDelta));
} catch (error) {
console.warn(error);
return;
}
}
}
}
Expected Behavior
blazor-hotreload
should load successfully and hot reload should work
Steps To Reproduce
- Create a hosted ASP.NET Core + Blazor WebAssembly Project
- Configure it to operate under a subdirectory (set base href, StaticWebAssetBasePath etc)
- Run the hosted project.
- Observe that
blazor-hotreload.js
loads correctly but requests_framework/blazor-hotreload
(relative to the subdirectory), breaking hot reload.
Repro: https://github.com/crackalak/BlazorHotReload404
Exceptions (if any)
No response
.NET Version
6.0.201
Anything else?
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Blazor WebAssembly Can Not Load Files 404 Not Found
I wanted to use .Net 6 hot reload features on my Blazor Webassembly app so I installed VS2022 Preview. When I tried to...
Read more >Blazor refresh route 404 error when moved _Host
I have a new Blazor Server project, I set up some new pages and placed them in an Areas/ subfolder. I move _Host...
Read more >How to fix Blazor WASM base path problems - elmah.io Blog
This post will show you how to fix a common problem when setting the application base path with Blazor WebAssembly.
Read more >Handling SPA Fallback Paths in a Generic ASP.NET Core ...
In this case in my Live Reload server, that's the 404 error page in the second screen shot. Handling Fallbacks with built-in EndPoints...
Read more >Hot Reload not so hot. : r/Blazor
I started it through the dotnet watch run command and hot reload worked fine for blazor server and wasm. skill issue maybe?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@danroth27 It works! Thanks!
For reference, all this code lives https://github.com/dotnet/sdk/tree/ea952247b79d17013e89c9b5ec82f1d6db830216/src/BuiltInTools/BrowserRefresh