Hot Reload
In Visual Studio and the dotnet CLI, we can enable Hot Reload. This means that as soon as we make changes in our application, our Blazor app will automatically get reloaded, and we will (in most cases) not lose the state.
To set this up, do the following:
- In Visual Studio, there is a small fire icon. We can use this button to trigger Hot Reload manually.
It is only clickable when the application is running (with or without debugging).
- Select the Hot Reload on File Save option.
- Start the project by pressing Ctrl + F5.
- In the web browser, bring up the counter page by adding
/counter
to the URL. - Make a change to the
/Pages/Counter.razor
file and click Save.
Our web browser should now reload, and the change will be shown. At the time of writing, my Hot Reload did not find any changes when running in Visual Studio, but it did work with dotnet watch
.
Hot Reload does save time and is pretty amazing. Not having to...