title: In Blazor Server-Side how can I detect if the user tries to navigate off of the current page
body: <p>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).</p>
  
  <p>I have <a href="https://stackoverflow.com/questions/2008806/how-to-detect-if-the-user-clicked-the-back-button">read posts</a> 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. </p>
  
  <p>I have also <a href="https://stackoverflow.com/questions/59980882/how-can-i-get-the-event-while-page-close-in-blazor-server-side">read posts</a> 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.</p>
  
  <p>Any recommendations on how to best handle this requirement?</p>