Skip to content

fix: re-execute status-code pages in their own DI scope#86

Merged
andregoepel merged 1 commit into
mainfrom
bugfix/status-code-pages-scope
Jul 12, 2026
Merged

fix: re-execute status-code pages in their own DI scope#86
andregoepel merged 1 commit into
mainfrom
bugfix/status-code-pages-scope

Conversation

@andregoepel

Copy link
Copy Markdown
Owner

Beim Verifizieren des Design-Upgrades in andregoepel-dev gefunden: UseStatusCodePagesWithReExecute("/not-found", "?code={0}") aus #83 re-executet im Service-Scope des Original-Requests. Hat der Request vorher schon eine Razor-Komponente gerendert (z. B. eine Host-Seite, die einen bare-4xx-Status setzt), crasht der zweite Render:

System.InvalidOperationException: 'RemoteNavigationManager' already initialized.
   at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.InitializeStandardComponentServicesAsync(...)

→ Response wird ein 500 statt der designten Fehlerseite.

Fix: createScopeForStatusCodePages: true (neuer .NET-10-Parameter, analog zum bestehenden createScopeForErrors: true am UseExceptionHandler), damit die Re-Execution frische scoped Services bekommt.

Build 0 Fehler, Tests 57/57 grün. Sollte als 1.2.1 released werden, da alle Consumer von UseAppFoundation() betroffen sind.

UseStatusCodePagesWithReExecute("/not-found") re-executed within the
original request's service scope. When that request already rendered a
Razor component — e.g. a host page that set a bare 4xx status — the
second render crashed with "'RemoteNavigationManager' already
initialized" and the response became a 500.

Pass createScopeForStatusCodePages: true (analogous to the existing
createScopeForErrors: true on UseExceptionHandler) so the re-executed
render gets fresh scoped services.
@andregoepel
andregoepel force-pushed the bugfix/status-code-pages-scope branch from 97521f9 to 5a98c94 Compare July 12, 2026 02:28
@andregoepel
andregoepel merged commit 7b557a2 into main Jul 12, 2026
3 checks passed
@andregoepel
andregoepel deleted the bugfix/status-code-pages-scope branch July 12, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant