Adding Blazor to MVC/Razor Pages
When I started with Blazor, this was exactly the scenario we wanted to address. We had an MVC/Razor Pages mix, and it was time for an upgrade.
We solved it by implementing Razor Pages that referred to Razor components. Looking back at it now, it was not a pretty solution, at least not for a while, until we got to the point where most of the code was rewritten in Blazor.
The challenge is that if we navigate to a page that has a Blazor component (a Razor component), that page is connected to the server and establishes a WebSocket. If we navigate away from a Blazor page to an MVC page, for example, we reload the entire page, and the script gets reloaded as well. A new connection was established, leaving the old one on the server for 3 minutes.
We don’t have many users, and for us, that technique works long enough for us to finish the migration and launch a new Blazor version of the site.
But I have some good news!
We can also...