Disabling Hot Reload for .NET Core project in Visual Studio 2019

Viewed 8398
6 Answers

You can change this feature here:

Tools > Options > Projects and Solutions > ASP.NET Core > Auto build and refresh option

Options to automatically build and refresh the browser if the web server is running when changes are made to the project.

Your options in this dropdown are the following:

  1. None
  2. Auto build on browser request (IIS only)
  3. Refresh browser after build
  4. Auto build and refresh browser after saving changes

Also note my version of VS is 16.11.1.

This isn't a great solution, but it's a viable workaround.

In the "Network" tab of Chromium Edge's developer tools, I found the request to load aspnetcore-browser-refresh.js. I right click on it and selected "Block URL". This prevents the script from loading.

With the CLI you have to do

dotnet watch run --no-hot-reload

In VS2022, unchecking the "Enable Hot Reload" setting under the projects Debug Properties disables the injection of the aspnetcore-browser-refresh.js script.

These screenshots show one way to access the setting:

Visual Studio debug menu

Visual Studio debug profile

in VS 2022 open launchSettings.json in the Properties folder

find your profile and add (see arrow, don't add arrow)

{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "profiles": {
    "Gang.Bingo.Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:7249;http://localhost:5249",
      "dotnetRunMessages": true,
      "hotReloadEnabled": false   <===========
    }
  }
}```

I had the same problem, go to Tools > Options > Debugging > General

and check this option Enable edit and continue and hot reload

enter image description here

Related