Skip to content

Blazor Web App is missing an error page #49853

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 · 3 comments
Closed

Blazor Web App is missing an error page #49853

danroth27 opened this issue Aug 3, 2023 · 3 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

When deployed to production a Blazor Web App will redirect server errors using app.UseExceptionHandler("/Error");. But there is nothing listening at /Error so you end up with a 404. Typically the error page is handled by a Razor Page, but in a Blazor Web App it should be a Blazor component page.

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Aug 3, 2023
@mkArtakMSFT mkArtakMSFT added feature-templates bug This issue describes a behavior which is not expected - a bug. labels Aug 3, 2023
@mkArtakMSFT mkArtakMSFT added this to the 8.0-rc1 milestone Aug 3, 2023
@danroth27
Copy link
Member Author

A few things to note about the existing Razor Pages based error page:

@SteveSandersonMS
Copy link
Member

Making this work end-to-end will be nontrivial. I've filed an issue with details at #50287. We might decide it's unwise to rush that for .NET 8.

In the meantime, let's use this issue to track what we're doing for the error page in the project template in .NET 8, since that's literally what the issue title is about.

Options for .NET 8

  1. Don't have a custom error page in the project template
    • Why should the default project template contain a custom error page? "We've always done it this way" doesn't count :)
    • Consider another tech like Next.js 13. Its default projects do not include custom error pages. To add one, you would follow docs, and even then it's limited to a statically (build-time) rendered HTML file. Clearly this is not universal enough that they wanted to put it in the default project.
    • People who want to add one would follow our docs and add a .cshtml or .html file.
  2. We could add /Pages/Error.cshtml. Note that it would not use the same layout, nor could it, since the Blazor layout will likely contain scripts for starting a circuit etc. As such it wouldn't accomplish much beyond the default built-in error output.

I'm changing the labels to make this reappear in triage.

@SteveSandersonMS SteveSandersonMS removed this from the 8.0 milestone Aug 23, 2023
@SteveSandersonMS SteveSandersonMS removed bug This issue describes a behavior which is not expected - a bug. feature-templates labels Aug 23, 2023
@SteveSandersonMS
Copy link
Member

also cc @danroth27

@mkArtakMSFT mkArtakMSFT added this to the 8.0-rc2 milestone Aug 23, 2023
@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Aug 23, 2023
@javiercn javiercn self-assigned this Aug 24, 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