How can I get the event while a page closes in Blazor Server side?

Platform: Blazor|Category: Components

You can use the IDisposable interface to invoke the Dispose event when a page navigation occurs or when a page is being closed. Below is a code example for your reference. 

@page "/"

@implements IDisposable;

<h1>Hello, world!</h1>

Welcome to your new app.

@code {

    public void Dispose()
    {

    }
}

View Sample in GitHub