question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`_framework/blazor-hotreload` 404 when running under subdirectory

See original GitHub issue

Is 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

  1. Create a hosted ASP.NET Core + Blazor WebAssembly Project
  2. Configure it to operate under a subdirectory (set base href, StaticWebAssetBasePath etc)
  3. Run the hosted project.
  4. 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?

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Dungecommented, Jun 14, 2022

@danroth27 It works! Thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found