A page is reloaded/refreshed automatically at a specified interval using “NavigationManager” in OnAfterRender() method. Here the NavigateTo(“url”, forceLoad: true) method, is used to force load the browser based on the URI.
@inject NavigationManager uriHelper;
@using System.Threading;
<h1>Hello, world!</h1>
Welcome to your new app.
@code {
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
var timer = new Timer(new TimerCallback(_ =>
{
uriHelper.NavigateTo(uriHelper.Uri, forceLoad: true);
}), null, 2000, 2000);
}
}
}
Share with