InvalidOperationException: 'RemoteNavigationManager' has not been initialized when used from DelegatingHandler in OnAfterRenderAsync

See original GitHub issue

Originally reported by @akorchev.

Repro steps:

  • Create a delegating handler that uses the NavigationManager to navigate.
  • Setup the delegating handler with HttpClient using HttpClient factory
  • In a Blazor Server app use the configured HttpClient from Index.razor in OnAfterRenderAsync.
System.InvalidOperationException: 'RemoteNavigationManager' has not been initialized.
   at Microsoft.AspNetCore.Components.NavigationManager.AssertInitialized()
   at Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(String uri, Boolean forceLoad)
   at BlazorApp5.MyDelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in C:\Users\user
[BlazorApp5.zip](https://github.com/aspnet/AspNetCore/files/3602254/BlazorApp5.zip)
[BlazorApp5.zip](https://github.com/aspnet/AspNetCore/files/3602256/BlazorApp5.zip)

\Source\Repos\BlazorApp5\BlazorApp5\MyDelegatingHandler.cs:line 25
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at BlazorApp5.MyService.DoHttpStuff() in C:\Users\user\Source\Repos\BlazorApp5\BlazorApp5\MyService.cs:line 26
   at BlazorApp5.Pages.Index.OnAfterRenderAsync(Boolean firstRender) in C:\Users\user\Source\Repos\BlazorApp5\BlazorApp5\Pages\Index.razor:line 11

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
pranavkmcommented, Sep 12, 2019

@rynowak do we think there’s room for some changes or do we resolve this as by design? It seems like anyone using their own DI scope is not going to have a good experience.

0reactions
msftbot[bot]commented, Nov 12, 2020

Thank you for contacting us. Due to a lack of activity on this discussion issue we’re closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn’t been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Blazor : System.InvalidOperationException ...
InvalidOperationException : 'RemoteNavigationManager' has not been initialized. at Microsoft.AspNetCore.Components.NavigationManager.
Read more >
DialogService does not work from Electron.Net
When using the DialogService in a Blazor page, it works, but not from my standard C# ... 'RemoteNavigationManager' has not been initialized.
Read more >
Blazor SignalR failre
Ok it is now throwing this error?? 'RemoteNavigationManager' has not been initialized. at Microsoft.AspNetCore.Components.NavigationManager.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found