dotnet / dotnet/aspnetcore

[Validation] The template Error page and its persisted RequestId

Open
#68,545 2 comments 0 reactions 1 assignee Claimed by @Yuvan111 View on GitHub
area-blazor Validation validation-scenario
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

**Scenario contact:** @ilonatommy

## Scenario

**This scenario validates that a reported bug is fixed.** The error page shows users a request ID they can quote to support. In an interactive app it rendered during prerendering and then vanished a moment later, when the app took over in the browser and the value was not carried across. The repro was as small as `dotnet new blazor -ai`, `dotnet run`, and navigating to the error page. ([#58434](https://github.com/dotnet/aspnetcore/issues/58434))

The error page is the one page that has to work when nothing else does, and it is the page least likely to be exercised, because reaching it means deliberately breaking the app.

## Minimum build

.NET 11 Preview 7 or later.

## Configurations to cover

* Blazor Web App
* [x] Static SSR
* [x] Interactive Server
* [ ] Interactive WebAssembly
* [x] Interactive Auto
* [ ] Standalone WebAssembly
* [ ] Hybrid (MAUI)

The reported bug needs the prerender-to-interactive handover, so build the app with `-ai` so every page including the error page goes through it. Static SSR is included as the case where the error page stays server-rendered and no handover happens.

## Also exercise

* [x] Published output
* [ ] An existing .NET 10 app upgraded to .NET 11
* [ ] Trimming or ahead-of-time compilation
* [ ] More than one server instance, or a proxy in front
* [ ] Hot Reload
* [ ] An IDE as well as the command line
* [ ] Container

## Setup

```bash
dotnet new blazor -n ErrorPageApp -int Server -ai
```

Run it outside Development, since that is when the error page is actually shown:

```bash
dotnet run --environment Production
```

Throttle the network in the browser. The reported symptom was a flash, so on a fast connection you may not catch it.

## What to build

Use the template's Error page exactly as generated.

Add several ways to break the app on purpose: a page that throws while rendering on the server, a page that throws once interactive, a page that throws while loading data, and a form whose submission throws.

## Things to try

* Triggering each deliberate failure and seeing where you land.
* Watching the request ID closely, with the network throttled, as the app becomes interactive behind the error page. Record the value before and after.
* Visiting `/Error` directly, with no error having occurred, since users bookmark and reload it.
* Reloading the error page, and navigating away and back.
* Comparing Development with Production, where Development shows more detail.
* Watching the browser console and the server log throughout.

## Expected behavior

The error page renders, keeps its request ID across the handover, and never becomes a second failure.

### Must hold

~~* Each deliberate failure that occurs lands on the error page rather than a blank page or the browser's own error page.~~
* Failures raised during an HTTP request, including static SSR and prerendering failures before the response starts, render the `/Error` page. Failures from interactive lifecycle methods or event handlers follow Blazor's interactive error handling and aren't expected to navigate to `/Error`.
* When `Error` is rendered, the request ID is visible in the prerendered page and is still the **same value** once the page becomes interactive. It does not flash and vanish, and it does not change.
* The error page throws nothing itself, and produces no secondary failure in the browser console or the server log.
* Visiting the error page directly, with no error to report, produces a working page.
* Development still shows its more detailed diagnostics.

## Evidence to capture

The request ID before and after the handover, and the server log for a navigation to the error page.

## Documentation to use

* [Prerendered state persistence in ASP.NET Core Blazor](https://learn.microsoft.com/aspnet/core/blazor/state-management/prerendered-state-persistence?view=aspnetcore-11.0)
* [Handle errors in ASP.NET Core Blazor apps](https://learn.microsoft.com/aspnet/core/blazor/fundamentals/handle-errors?view=aspnetcore-11.0)

## What to report

Report results using the format described in the [validation testing manual](https://github.com/dotnet/aspnetcore/issues/68479). Include link to a repository with the test app.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.