InvalidOperationException: 'RemoteNavigationManager' has not been initialized when used from DelegatingHandler in OnAfterRenderAsync
See original GitHub issueOriginally reported by @akorchev.
Repro steps:
- Create a delegating handler that uses the
NavigationManagerto navigate. - Setup the delegating handler with
HttpClientusing 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:
- Created 4 years ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
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!