dotnet / dotnet/aspnetcore

[Hot Reload with dotnet watch][Unstable] Create a 11.0 Blazor Web App project, update and save the .css file, and then refresh the browser, the project will revert to its previous state

Open
#66,089 10 comments 1 reaction 1 assignee Claimed by @kotlarmilos View on GitHub
area-blazor feature-hot-reload untriaged
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

**REGRESSION INFO** Works well in 10.0.201 and 10.0.300-preview SDK
Also repro in .NET 11.0 preview 1 SDK

**INSTALL STEPS**
1. Clean Win11 x64 25h2 ENU
2. Install the .NET 11.0 preview 2 SDK from corhont build
3. Add feed

**Platform**
- [x] Windows
- [ ] macOS
- [ ] Linux

**Repro Steps**
1. Open a normal Command Prompt
2. Create a Blazor Web App for Server project, and run it using `dotnet watch`
```
dotnet new blazor -int Server -o MyBlazorServerApp
cd MyBlazorServerApp
dotnet watch
```
3. Press `Ctrl + C` to stop the `dotnet watch`
4. Then run it using `dotnet watch` again
5. Open Components/Layout/MainLayout.razor.css in Notepad, update the `.page` selector:
```
.page {
position: relative;
display: flex;
flex-direction: column;
+ background-color: orange;
```
4. Save the change, the browser update to display the color
5. Refresh the browser, view the browser

**Actual Result**
The page will return to the previous state after refresh the browser.

![Image](https://github.com/user-attachments/assets/db17af0e-5f1b-4948-b4a5-fe339687a142)

**Note:**
1. This issue doesn't repro with 10.0.201 SDK(March Servicing build) and 10.0.300-preview build.
2. This issue doesn't repro Blazor WebAssembly Standalone project.
3. This issue also repro on Blazor web app for Wasm project.
4. This issue also repro on wwwroot/app.css file, does not repro on .razor file.

**Error Log**

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.