Closed
Description
When I try to trigger the exception handler middleware by throwing an exception from a Blazor Web App I get an exception about RemoveNavigationManager
being already initialized.
Repro steps:
- Install .NET 8 Preview 7
- Create a Blazor Web App
- Add a Pages/Error.razor component (see Blazor Web App is missing an error page #49853)
- In Index.razor add an
OnInitialized
method that throws an exception - Change the launch environment to Production
- Run the app and browse to the home page
Expected result: Exception is thrown and handled by the exception handler middleware so the error page is rendered.
Actual result:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[3]
An exception was thrown attempting to execute the error handler.
System.InvalidOperationException: 'RemoteNavigationManager' already initialized.
at Microsoft.AspNetCore.Components.NavigationManager.Initialize(String baseUri, String uri)
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.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)