question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HotReload is not working in ASP.NET Core in VS2022 or dotnet watch run when ServiceWorkers are installed/running

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
msftbot[bot]commented, Feb 1, 2022

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.

1reaction
SteveSandersonMScommented, Jan 26, 2022

Some of the destinations such as images, videos, audio etc seem like the wrong place to be injecting scripts in to

We might be able to filter on accept: text/html to avoid those, but I take your point that moving conservatively is wise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Reload not working in Visual Studio 2022 .Net 6 Razor ...
Refreshing the page doesn't seem to show the updates either. The ASP.NET Core 3.1 project hot reload is working as expected. When we...
Read more >
NET Hot Reload support for ASP.NET Core
NET Hot Reload to apply code changes to a running app without ... Hot Reload, pass the --no-hot-reload option to the dotnet watch...
Read more >
Is it possible to use hot reload while debugging in VsCode?
What I want to achieve is to start a debug session, put some breakpoints, make small changes and keep debugging with new breakpoints...
Read more >
Attach to dotnet watch with hot-reload: Debugger operation ...
I start my blazor application with “dotnet watch run” in terminal and make changes to razor files, the hot reload triggers and refreshes...
Read more >
Let's talk about the removal of hot reload from dotnet watch ...
Become a Patreon and get source code access: https://www.patreon.com/nickchapsas Check out my courses: https://dometrain.com Keep coding ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found