How to automatically reload .NET Core project in Visual Studio 2019

Akash Limbani picture Akash Limbani · Nov 25, 2019 · Viewed 17.7k times · Source

I tried to automatically reload ASP.NET Core project as I do using Angular with Node or NPM.

When I change the code of the .NET Core project and save, I want the web page to be automatically refreshed in the web browser.

Answer

Amir Dora. picture Amir Dora. · Apr 26, 2020

run this command in project console

dotnet watch run

same works for visual studio code

From Develop ASP.NET Core apps using a file watcher (for 3.0)

dotnet watch is a tool that runs a .NET Core CLI command when source files change. For example, a file change can trigger compilation, test execution, or deployment.

The link above contains a tutorial with two sample projects:

  1. WebApp (an ASP.NET Core web API) and
  2. WebAppTests (unit tests for the web API).

Alternatively, you can also this nuget package for runtime compilation.