Disable ASP.NET Core hot reload script from frontend

99 Views Asked by At

Sometimes I make changes in my IDE and don't want the page to be reloaded in the browser after I save. A typical scenario is that I make changes to the page via the devtools, and if the page is reloaded then those changes would be lost; or perhaps I'm interacting with some remote API and don't want to lose such state.

There are ways to disable hot reload, but that's not what I want - I want to keep using it, but to disable it per page, on demand, from the frontend itself. For example, I want to inject a button into the page with a script that disables hot reload.

The _framework/aspnetcore-browser-refresh.js script is here.

The obvious solution is to clear the script's timeout, but it uses setTimeout without saving the id.

I tried this without success:

window['_dotnet_watch_ws_injected'] = 1;

What else could I try?

0

There are 0 best solutions below