Skip to content

Revisit hot reload browser refresh script injection #45213

@MackinnonBuck

Description

@MackinnonBuck

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 </body> tag in HTML responses and injects a <script src="/_framework/aspnetcore-browser-refresh.js"></script> 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 </body> 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pillar: Dev ExperiencePriority:1Work that is critical for the release, but we could probably ship withoutarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-hot-reloadThis issue is related to the Hot Reload feaaturetriaged

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions