How to refresh page in Blazor development process after code changing

Viewed 5514

For me, a biggest discomfort of Blazor development is absent to simple refreshing page after tiny changing HTML of style in source code. Since ASP.NET was born this opportunity has been present - we changing something in HTML or in code, than simple click refresh in browser and new page instantly was appear in browser. But in Blazor development even after tiny changing code or HTML we must stop web server then start full compilation sourse code again and after compilation has been ended successfully IIS will be started and Browser will be started. And even after that HTML-page will be showing in Browser. In Classic ASP.NET we was have even more faster development method - Designer of Visual Studio with directly showing any HTML-changing. Current Blazor development process slows down speed of Web-development for millions times. Is this possible to restore convenient ASP.NET workflow of web-development in Blazor at least to the MVC development speed (with simple refresh page in Browser without recompliation and restarting all development components after tiny changing of code or HTML?

2 Answers

There is a commercial solution called LiveSharp.net which solves most of your problems. They offer a free trial. I personally use it and it really saves a lot of time, especially when doing CSS / HTML tweaking.

In addition, .NET 6 is announced to offer hot reload out of the box.

<script>
    Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
        document.location.reload();
    }
</script>

Paste it in _Host.cshtml file (or your custom host file) in the body section like this:

Related