dotnet / dotnet/aspnetcore

Adding server side blazor breaks hot reloading of regular razor pages

Open
#52,453 3 comments 0 reactions 0 assignees View on GitHub
area-blazor feature-hot-reload
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

As soon as I add a `_framework/blazor.server.js` it breaks the "live" hot reload for regular Razor Pages (.cshtml). Console says "Hot reload of changes succeeded" as it should, checkmark is visible on the top left corner of the page (I assume it's from blazor itself, as that doesn't happen without it), but the content on page doesn't change until a proper browser refresh. Feels like it interferes with the connection that's used by `dotnet watch`.

### Expected Behavior

Hot reload should update the view without refreshing the page, as it does when _not_ using Blazor.

### Steps To Reproduce

1. Create a new project using `dotnet new razor`.
2. Start with `dotnet watch`.
3. Change any content in `_Layout.cshtml` and observe the changes applied live without requiring a refresh.
4. Add services using `services.AddServerSideBlazor()` and map blazor hub using `app.MapBlazorHub()`.
5. Restart `dotnet watch`.
6. Change any content in `_Layout.cshtml` and observe the changes applied live without requiring a refresh.
7. Add `` to your `_Layout.cshtml` so the blazor server connection is started.
8. Change any content in `_Layout.cshtml` and observe no live updates and a "liar" tick icon appearing briefly. Page needs to be refreshed to see the changes.

### Exceptions (if any)

_No response_

### .NET Version

8.0.100

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.