-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When created brand new ASP.NET Core 6 project and added ServiceWorker JavaScript code (for caching, offline handling etc.) HotReload functionally is not loading.
IMVHO it is related to the fact that key messing ingredient SignlaR script:
<script src="/_framework/aspnetcore-browser-refresh.js"></script>
is not loaded. Why ?? don't know.
So in order to make it behave properly user is obliged to load manually this script (for example by including it in _Layout)
After that all is back to normal again. The script is simply not emitted when Service Worker are installed and running.
Same behavior is observer when run with Ctrl-F5 in VS2022 and through CLI -> dotnet watch run
Rerpro project demonstrating the issue
Expected Behavior
When ServiceWorker is installed and running hotReload should work out of the box in VS2022 and through dotnet watch run
Steps To Reproduce
https://github.com/ChaosEngine/NoHotReloadWithServiceWorker
Important pieces:
NoHotReloadWithServiceWorker\wwwroot\sw.js - Service worker
NoHotReloadWithServiceWorker\wwwroot\js\site.js - code loading sw.js
NoHotReloadWithServiceWorker\Pages\Shared_Layout.cshtml - place where <script src="/_framework/aspnetcore-browser-refresh.js"></script>
is injected manually
NoHotReloadWithServiceWorker\Pages\Index.cshtml - page which aftter modification should auto-refresh in SignalR-connected browser
Exceptions (if any)
No response
.NET Version
6.0.101
Anything else?
VS2022 - Professional Version 17.0.5
$ dotnet --info
Zestaw .NET SDK (odzwierciedlenie dowolnego pliku global.json):
Version: 6.0.101
Commit: ef49f6213a
Środowisko uruchomieniowe:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.101\
Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc
.NET SDKs installed:
5.0.404 [C:\Program Files\dotnet\sdk]
6.0.101 [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 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download