Open MackinnonBuck opened 2 days ago
@MackinnonBuck thanks for the thorough report.
I imagine this doesn't happen with .NET 9.0 apps? I also imagine that doing a hard refresh with CTRL+F5 will also work?
Also, is it fair to say that this is not a new thing, but something that has happened since we added the feature? (Since I imagine this is caused by the lack of proper cache-control
headers).
I imagine this doesn't happen with .NET 9.0 apps?
This actually does repro with .NET 9 apps (Blazor WebAssembly standalone). In both .NET 8 and .NET 9, the Cache-Control
header has the value max-age=0
.
I also imagine that doing a hard refresh with CTRL+F5 will also work?
Yeah, ctrl+F5 also works
Also, is it fair to say that this is not a new thing, but something that has happened since we added the feature?
I'm not sure how far back the bug goes - I haven't tried it on .NET 6/7 yet.
Is there an existing issue for this?
Describe the bug
dotnet watch
may not inject theaspnetcore-browser-refresh.js
script for Blazor WebAssesmbly standalone apps. This is because the cached result ofindex.html
gets used, and this bypasses the script injection middleware.For example, if you run a default Blazor WebAssembly standalone app first using
dotnet run
, then the response forindex.html
will not include the browser refresh script (which is expected). Subsequently runningdotnet watch
will result in that sameindex.html
getting used (without the injected script). Clearing the browser cache results in the script injection middleware re-running, and hot reload will work as expected.Note that:
Expected Behavior
Caching does not interfere with hot reload script injection, and
dotnet watch
works regardless of whetherdotnet run
was executed prior to it.Steps To Reproduce
dotnet new blazorwasm
dotnet run
ctrl+c
)dotnet watch
aspnetcore-browser-refresh.js
script was not injected into the documentaspnetcore-browser-refresh.js
script was injected into the documentExceptions (if any)
No response
.NET Version
9.0.200-preview.0.24529.19
Anything else?
Was also able to repro using .NET SDK version 8.0.404.
Output of dotnet --info
```text .NET SDK: Version: 9.0.200-preview.0.24529.19 Commit: 3980fbc52d Workload version: 9.0.200-manifests.c6f19616 MSBuild version: 17.13.0-preview-24529-12+ee511a938 Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\9.0.200-preview.0.24529.19\ .NET workloads installed: [tvos] Installation Source: VS 17.13.35517.34 Manifest Version: 18.0.9617/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.tvos\18.0.9617\WorkloadManifest.json Install Type: Msi [macos] Installation Source: VS 17.13.35517.34 Manifest Version: 15.0.9617/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.macos\15.0.9617\WorkloadManifest.json Install Type: Msi [maui-windows] Installation Source: VS 17.13.35517.34 Manifest Version: 9.0.0/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.0\WorkloadManifest.json Install Type: Msi [maccatalyst] Installation Source: VS 17.13.35517.34 Manifest Version: 18.0.9617/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.0.9617\WorkloadManifest.json Install Type: Msi [ios] Installation Source: VS 17.13.35517.34 Manifest Version: 18.0.9617/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.0.9617\WorkloadManifest.json Install Type: Msi [android] Installation Source: VS 17.13.35517.34 Manifest Version: 35.0.7/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.7\WorkloadManifest.json Install Type: Msi [wasm-tools-net6] Installation Source: VS 17.13.35517.34 Manifest Version: 9.0.0/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.net6\9.0.0\WorkloadManifest.json Install Type: Msi [wasm-tools-net7] Installation Source: VS 17.13.35517.34 Manifest Version: 9.0.0/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.net7\9.0.0\WorkloadManifest.json Install Type: Msi [wasm-tools-net8] Installation Source: VS 17.13.35517.34 Manifest Version: 9.0.0/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.net8\9.0.0\WorkloadManifest.json Install Type: Msi [wasm-tools] Installation Source: VS 17.13.35517.34 Manifest Version: 9.0.0/9.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.0\WorkloadManifest.json Install Type: Msi [aspire] Installation Source: VS 17.13.35517.34 Manifest Version: 8.2.2/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json Install Type: Msi Configured to use loose manifests when installing new manifests. Host: Version: 9.0.0 Architecture: x64 Commit: 9d5a6a9aa4 .NET SDKs installed: 8.0.404 [C:\Program Files\dotnet\sdk] 9.0.100 [C:\Program Files\dotnet\sdk] 9.0.200-preview.0.24529.19 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.32 [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.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [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.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 9.0.0-rc.2.24474.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 9.0.0 [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 ```