dotnet / dotnet/aspnetcore

Revisit hot reload browser refresh script injection

Open
#45,213 8 comments 38 reactions 1 assignee Claimed by @maraf View on GitHub
area-blazor enhancement feature-hot-reload on-roadmap Pillar: Dev Experience Priority:1 triaged
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

Our hot reload mechanism relies on the `aspnetcore-browser-refresh.js` script being injected into the webpage so the browser can automatically refresh with hot reload changes.

We currently do this with a special middleware that searches for the last closing `` tag in HTML responses and injects a `` element just before it. However, this mechanism is very fragile because it fails when the response can't be easily parsed (e.g., response compression is enabled, the closing `` tag is split between response stream writes, etc.).

We should consider an approach where we somehow reference the browser refresh script directly rather than using this script injection middleware.

## Additional considerations

Make sure we also address the following issues:
- [ ] https://github.com/dotnet/aspnetcore/issues/33068
- [ ] https://github.com/dotnet/aspnetcore/issues/39715

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.