Route or Navigate and Force Reload Page in Blazor

Route or navigate to other pages and force reload page in Blazor webassembly Application

October 2, 2020

In this article we will cover how to route or navigate to the specified page and force reload page in Blazor webassembly Application.

Step 1 : We need to Inject NavigationManager in our component

Step 2 : Call NavigateTo Method with specified URI and force load parameters

Example Code

using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;
 
namespace HpBlogs.Pages
{
    public partial class Demo : ComponentBase
    {
        [Inject]
        public NavigationManager navigationManager { getset; }
 
        protected async override Task OnInitializedAsync()
        {
            //SIMPLE ROUTE
            navigationManager.NavigateTo("/aboutus");
 
            //ROUTE AND FORSE RELOAD
            navigationManager.NavigateTo("/contactus"true);
        }
    }
}

Post Comments(0)

Leave a reply

Will not be displayed in comment box .

Loading...