ASP.NET - Live Reload During Development
Live Reload is a development feature that automatically refreshes the browser or reloads the application when code changes are saved. It removes the need to stop, rebuild and restart the app manually, allowing developers to see updates instantly while working.
Why Live Reload Is Useful
During development, frequent small changes are common. Without live reload, each change requires restarting the app, which slows learning and testing. Live reload shortens this feedback loop, helping developers quickly understand how code changes affect output.
How Live Reload Works
ASP.NET Core watches project files for changes. When a file is saved, the development server detects the change and either refreshes the browser or reloads the app automatically. This happens only in the development environment and does not affect production.
dotnet watch and Hot Reload
The dotnet watch tool enables live reload from the command line. It monitors files and restarts or updates the app when changes occur. Hot Reload goes a step further by applying some code changes without restarting the application, keeping state intact when possible.
What Can Be Reloaded Automatically
Changes to controllers, Minimal API endpoints, Razor pages, CSS and some C# logic can reload instantly. Structural changes, such as adding new services or changing startup configuration, may still require a full restart.
Why It’s Safe for Production
Live reload runs only in development mode. In production, file watching and automatic reload features are disabled, ensuring stability and performance for end users.
Example
dotnet watch run
After running this command:
-
Save a file like
Program.cs -
The app reloads automatically
-
Browser refreshes or updates output instantly
This allows fast testing and smoother learning during ASP.NET Core development.