Skip to content

[Blazor] Error page support #49854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danroth27 opened this issue Aug 3, 2023 · 0 comments
Closed

[Blazor] Error page support #49854

danroth27 opened this issue Aug 3, 2023 · 0 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@danroth27
Copy link
Member

danroth27 commented Aug 3, 2023

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)
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Aug 3, 2023
@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Aug 7, 2023
@mkArtakMSFT mkArtakMSFT added this to the 8.0-rc2 milestone Aug 7, 2023
@javiercn javiercn changed the title InvalidOperationException: 'RemoteNavigationManager' already initialized. [Blazor] Error page support Sep 6, 2023
mkArtakMSFT pushed a commit that referenced this issue Sep 20, 2023
…Applications (#50550)

## Description

Adds support for Error pages to Blazor Web application.
* Includes a small change to the ExceptionHandler middleware to support Blazor Web scenarios.
* Includes a change in Blazor Web to account for error handling scenarios and disable streaming rendering and interactivity.
* Includes changes to the Blazor Web template to add an Error page similar to the one in MVC and Razor pages templates.

Fixes #49853, #49854

## Customer Impact

* Customers won't be able to see errors in Blazor Web Applications without having to rely on MVC or Razor Pages for it,
  which adds significant complexity to their setup.

## Regression?

- [ ] Yes
- [X] No

## Risk

- [ ] High
- [X] Medium
- [ ] Low

* If customers hit any issues, we will be able to tell them to simply remove the ErrorPage.razor page from their projects. Luckily, we will have a little bit of time to address any critical feedback in case such comes up. As of right now, this change has been validated and it works.

## Verification

- [X] Manual (required)
- [X] Automated

## Packaging changes reviewed?

- [ ] Yes
- [ ] No
- [X] N/A
@ghost ghost locked as resolved and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

4 participants