I am working on an ASP.NET Core 3.1 Blazor Server-Side application that has a Blazor component with an EditForm. I want to warn the user that they have unsaved data if they try to navigate off of the page (i.e. click the browser back button or make a Nav menu selection that loads another page within the same application).
I have read posts about using the javascript window.onbeforeunload but I was not sure if invoking javascript on a Blazor server-side would mess up the SignalR connection.
I have also read posts about using a CircuitHandler but I wan't sure if the SignalR circuit changed if the user just moves to a different page in the same application.
Any recommendations on how to best handle this requirement?
window.onbeforeunload
via JS Inetrop. I wrote a lib time ago, at this time is deprecated but you can see the idea: github.com/ctrl-alt-d/BlazorConfirm – Chap