Skip to content

HttpNavigationManager already initialized on Blazor SSR. #49456

Closed as not planned
@benjaminsampica

Description

@benjaminsampica

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm trying to use the UseExceptionHandler middleware to handle exceptions thrown when Blazor server-side rendering pages and am receiving an unexpected error when the middleware executes.

Expected Behavior

The request re-executes and I'm sent to my error page.

Steps To Reproduce

  1. Create a new blazor web project - dotnet new blazor
  2. Create an /Error page (the template is missing this page despite having the exception handler go there).
  3. Run the project with anything other than the Development environment.

These steps in a repo -> https://github.com/benjaminsampica/BlazorServerSideRendering

Exceptions (if any)

System.InvalidOperationException: 'HttpNavigationManager' already initialized.
   at Microsoft.AspNetCore.Components.NavigationManager.Initialize(String baseUri, String uri)
   at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.InitializeStandardComponentServicesAsync(HttpContext httpContext, Type componentType, String handler, IFormCollection form)
   at Microsoft.AspNetCore.Components.Endpoints.RazorComponentEndpointInvoker.RenderComponentCore()
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<<InvokeAsync>b__9_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
Microsoft.AspNetCore.Server.Kestrel: Error: Connection id "0HMS6ET6U8UL7", Request id "0HMS6ET6U8UL7:00000001": An unhandled exception was thrown by the application.

.NET Version

.NET 8 preview 6

Anything else?

No response

Metadata

Metadata

Labels

Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions