title: How can I get the event while page close in blazor server-side?
body: <p>I am making a chatroom App by the blazor server-side.</p>
  
  <p>I want to show the online state of each user.</p>
  
  <p>Now I can use the <code>OnAfterRenderAsync</code> event to get a user has entered the page.</p>
  
  <p>It seems there is not any <code>exit</code> event in blazor lifecycle via <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/lifecycle?view=aspnetcore-3.1" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/blazor/lifecycle?view=aspnetcore-3.1</a></p>
  
  <p>Someone said I can use the <code>Dispose</code> event to achieve it while it does work at all.</p>
  
  <p>What's more, I have a crazy idea that using the <code>window.onbeforeunload</code> event of js to invoke the blazor method.</p>
  
  <p>I have no idea which one is best. Would you please give me a suggestion? Thank you.</p>