Open DamianEdwards opened 1 year ago
This is also needed when using front end frameworks which have their own HMR. Getting whole page refresh on controller change isn't really necessary and results in lost state.
I would also add that this should work in mixed environments where you have blazor on the page that you want to hot reload and you have a razor page that you want the server side rendering to reload separately
Currently the script aspnetcore-browser-refresh
script explicitly denies this capability.
function aspnetCoreHotReloadApplied() {
if (window.Blazor) {
// If this page has any Blazor, don't refresh the browser.
notifyHotReloadApplied();
} else {
location.reload();
}
}
While not perfect, you can already disable the middleware responsible for injecting the JavaScript by using the ASPNETCORE_HOSTINGSTARTUPEXCLUDEASSEMBLIES
environment variable. See: https://github.com/dotnet/aspnetcore/issues/33068#issuecomment-1699509484 .
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Thanks for contacting us.
We're moving this issue to the .NET 9 Planning
milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
As a result of the problems experienced by some customers in their ASP.NET Core apps when the browser refresh script is auto-injected, as detailed in #32767, I’m proposing that we add a new launch settings/profile property that can be used to disable the automatic injection of the browser refresh script.
The property would be named
disableBrowserRefreshScriptInjection
and would default tofalse
. Setting this property totrue
in a launch profile inlaunchSettings.json
would preventdotnet watch
and Visual Studio from injecting the middleware that writes out the browser refresh JavaScript to HTML responses from the app, e.g.:Note that this setting should not disable any other part of the mechanism that enables browser refreshing on Hot Reload, project build, CSS file change, etc., so that the app can manually add the required JavaScript reference manually, e.g.