protected override async Task OnInitializedAsync() { NavigationManager.LocationChanged += NavigationManagerOnLocationChanged; // access to uri on first page load Logger.LogInformation(NavigationManager.ToBaseRelativePath(NavigationManager.Uri)); } private void NavigationManagerOnLocationChanged(object? sender, LocationChangedEventArgs e) { // access to uri on change Logger.LogInformation(NavigationManager.ToBaseRelativePath(NavigationManager.Uri)); }
References
https://stackoverflow.com/questions/50102726/get-current-url-in-a-blazor-component