Blazor — Enable Auto Reload or Hot Loading in server-side ASP.net Core App [Simple way]

Blazor — Enable Auto Reload or Hot Loading in server-side ASP.net Core App [Simple way]

·

2 min read

In this blog post, I extend my experience in Blazor server-side auto-reload or hot-reload whatever you say. 1_xCobyQWvtNXWungQtFn-vw.png

I started to learn blazor since December 2019 and started a project named “Online Exam System” so in this project when I change anything in my code it and I go back in browser I got this …

1_JBFWO-J6dMPnvqToIQI8-w.png

It takes a couple of times and too boring to manually reload the page again and again whatever you change in code. All of a sudden I got a solution from StackOverflow and it worked for me. So that, I overcome the blazor manually auto-reload problem. Here is the solution :

  1. Copy the code
<script>
        Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
            document.location.reload();
        }
    </script>
  1. Paste it on _Host.cshtml file in the body section of your project, like that 1_Pgcbvr4ZiG4qaZQYCFLG8g.png

It’s work when you run the project “Start Without Debugging” and change anything design or code. Then It automatically takes some seconds to auto-reload in browser.

1_A4taFuYhs_7Yf1eURbqYhw.jpeg

  1. Done, Now Check on it. This is my second Medium Blog post if I have any mistake Let me know then. Thanks ( avoid grammar )

Happy Coding

I’m Sefat

Full-Stack Developer ( .Net )

Originally Published on : medium.com/@sefatanam/blazor-enable-auto-re..