Hot reload (almost the real thing)
With .NET 5, we got the ability to reload our Blazor site when we make changes to a code file. Users have asked for hot reload and Microsoft is aiming to release hot reload in the .NET 6 timeframe.
To set this up, do the following:
- In Visual Studio, select the Tools menu and then Options.
- Select Projects and Solutions and then ASP.NET Core.
- In the right box under the General heading, change the value of the Auto build and refresh option to Auto build and refresh browser after saving the changes.
- Right-click on MyBlogServerSide and select Set as Startup project.
- Now run the project by pressing Ctrl + F5 (it only works without debugging).
- 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.
This also works from the command line by running the following command...