HotReload is not working in ASP.NET Core in VS2022 or dotnet watch run when ServiceWorkers are installed/running
See original GitHub issueIs 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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top GitHub Comments
Thanks for contacting us.
We’re moving this issue to the
.NET 7 Planning
milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. 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 issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.We might be able to filter on
accept: text/html
to avoid those, but I take your point that moving conservatively is wise.