dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.23k stars 9.95k forks source link

Blazor wasm hosted in a subfolder doesn't hot reload on changing #44568

Closed drocha87 closed 11 months ago

drocha87 commented 1 year ago

Is there an existing issue for this?

Describe the bug

Hot reload is not updating the changes when setup a new project with a blazor hosted in a sub folder.

Expected Behavior

Refresh the page with the new content when changing the hosted blazor wasm application.

Steps To Reproduce

git clone https://github.com/drocha87/BlazorWasmHostedHotReloadProblem.git
cd BlazorWasmHostedHotReloadProblem
cd Server
dotnet watch --project .

These commands will open you browser in a main page which is not the blazor wasm page, in the navigation bar type /app which will load the blazor wasm application.

Open your favorite text editor and change the Client/Pages/Index.razor save the file.

In the browser you can see that it triggered the hot reload, but nothing will change, even if you reload through the browser.

Your changed will be visible only if you "rebuild" the project typing ctrl r on the terminal where the command dotnet watch --project . is running.

You can see that the project structure on sources in the browser is like the following.

image

And the network tab show that trying to load the blazor-hotreload return 204 (no content).

image

I also noticed that in blazor-hotreload.js this piece of code is returning 204 (which is showed above)

  const response = await fetch('/_framework/blazor-hotreload', { headers });
  if (response.status === 200) { // <----------- status code 204
    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;
      } 
    }
  }

If we don't enter this branch (because the status code is not 200) we don't call applyHotReload defined in blazor.webassembly.js

This is the output of running the dotnet watch --project . -v verbose

dotnet watch ⌚ File changed: ...\BlazorWasmHostedHotReloadProblem\Client\Pages\Index.razor.
dotnet watch ⌚ No deltas modified. Applying changes to clear diagnostics.
dotnet watch ⌚ Received 0 from browser in [Count: 0, MessageType: Close, EndOfMessage: True].
dotnet watch ⌚ No hot reload changes to apply.
dotnet watch 🔥 Hot reload change handled in 545.0921ms.

If you guys need more information just tell me.

Exceptions (if any)

No response

.NET Version

7.0.100-rc.2.22477.23

Anything else?

ASP.NET Core version: Microsoft.AspNetCore.App 7.0.0-rc.2.22476.2 The IDE: Vs Code

The output of dotnet --info

.NET SDK:
 Version:   7.0.100-rc.2.22477.23
 Commit:    0a5360315a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\

Host:
  Version:      7.0.0-rc.2.22472.3
  Architecture: x64
  Commit:       550605cc93

.NET SDKs installed:
  6.0.305 [C:\Program Files\dotnet\sdk]
  6.0.402 [C:\Program Files\dotnet\sdk]
  7.0.100-rc.2.22477.23 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-rc.2.22476.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-rc.2.22472.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
ghost commented 1 year ago

To learn more about what this message means, what to expect next, and how this issue will be handled you can read our Triage Process document. We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. Because it's not immediately obvious what is causing this behavior, we would like to keep this around to collect more feedback, which can later help us determine how to handle this. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact work.

ghost commented 11 months ago

To learn more about what this message means, what to expect next, and how this issue will be handled you can read our Triage Process document. We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. Because it's not immediately obvious what is causing this behavior, we would like to keep this around to collect more feedback, which can later help us determine how to handle this. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact work.

mkArtakMSFT commented 11 months ago

Hi. Thanks for contacting us. We're closing this issue as there was not much community interest in this ask for quite a while now. You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

GillesTourreau commented 10 months ago

@mkArtakMSFT When Microsoft plan to fix this issue ? Because when we have multiple WebAssembly application hosted in a same web app, we can't use the hotreload, specially for the HTML/CSS integrators...