Skip to content

_framework/blazor-hotreload 404 when running under subdirectory #40971

Closed
@crackalak

Description

@crackalak

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 #36897, but this is the second part of #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

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-hot-reloadThis issue is related to the Hot Reload feaature

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions