System.InvalidOperationException: ''RemoteNavigationManager' has not been initialized.'

Has anyone seen this behavior:

this.baseUri = new Uri($"{navigationManager.BaseUri}odata/Identity/"); is throwing exception: 'System.InvalidOperationException: ''RemoteNavigationManager' has not been initialized.' when I call NavigationManager.NavigateTo(query.ToUrl( ...);

public SecurityService(NavigationManager navigationManager, IHttpClientFactory factory)
{
this.baseUri = new Uri($"{navigationManager.BaseUri}odata/Identity/");
this.httpClient = factory.CreateClient("TEST");
this.navigationManager = navigationManager;
}

It only blows up when I use NavigationManager.NavigateTo. Any clues or ideas would be helpful. Thanks

Maybe you are trying to use it in the server app of hosted web assembly application.

How can I fix that?

Not sure I fully understand what you are saying but any guidance would be appreciated. What is confusing is that SecurityService injects and uses naviationmanager for everything else in the app except for when I use navigateto.

Appreciate your help.

By the way, this is happening in my dev env as well.

You can’t fix something that isn’t supposed to be working. NavigationManager cannot work in a non Blazor application.

Maybe you can visit Microsoft official documentation for such questions.