I have a Blazor WebAssembly project which I start locally by using dotnet watch run. When I do this, I get the following output:
C:\dev\BlazorRater\BlazorRater.UI [master ≡ +1 ~5 -1 !]> dotnet watch run
watch : Started
Building...
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\dev\BlazorRater\BlazorRater.UI
In the browser console, the following gets logged on the initial load:
Debugging hotkey: Shift+Alt+D (when application has focus)
blazor.webassembly.js:1 blazor Loaded 8.87 MB resourcesThis application was built with linking (tree shaking) disabled. Published applications will be significantly smaller.
(index):28 WebSocket connection to 'ws://127.0.0.1:51489/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
(anonymous) @ (index):28
When I make a change to a .razor, .razor.css, or .cs, the browser doesn't automatically reload.
If I then do a Ctrl+F5 to reload my app, I do not get the WebSocket connection failure in the console:
Debugging hotkey: Shift+Alt+D (when application has focus)
blazor.webassembly.js:1 blazor Loaded 8.87 MB resourcesThis application was built with linking (tree shaking) disabled. Published applications will be significantly smaller.
and now when I make a change to a .razor, .razor.css, or .cs file the browser will automatically reload with my changes.
Why on initial load am I getting a WebSocket error, but don't when I perform a Ctrl+F5? Also, a Ctrl+R does not solve the WebSocket issue. Only a Ctrl+F5 fixes it.