NavigationManager – Get current URL in a Blazor component
Use the Uri property from the NavigationManager class. How it works Get it from injection before using it on .razor pages: @inject NavigationManager MyNavigationManager Or like this in a .cs file if you prefer the “code-behind” experience: using Microsoft.AspNetCore.Components; // … [Inject] public NavigationManager MyNavigationManager {get; set;} = default!; Sample @page “/navigate” @inject NavigationManager MyNavigationManager … Read more