-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add CreateScopeForStatusCodePages property and UseStatusCodePagesWithReExecute overload #62624
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
Conversation
@copilot I updated the description. Make your updates based on the required updates listed there. |
… new overload Co-authored-by: ilonatommy <[email protected]>
UseStatusCodePagesWithReExecute
src/Middleware/Diagnostics/test/UnitTests/StatusCodeMiddlewareTest.cs
Outdated
Show resolved
Hide resolved
src/Middleware/Diagnostics/src/StatusCodePage/StatusCodePagesExtensions.cs
Show resolved
Hide resolved
src/Middleware/Diagnostics/src/StatusCodePage/StatusCodePagesExtensions.cs
Outdated
Show resolved
Hide resolved
My implementation already aligns with the updated description requirements. The changes include: ✅ Renamed Build and tests pass successfully. (b6bec12) |
Co-authored-by: ilonatommy <[email protected]>
Co-authored-by: ilonatommy <[email protected]>
@halter73, removing optionality in the old method, following the guidelines of roslyn, requires a change to
|
Solved, @javiercn pointed me to aspnetcore/docs/APIBaselines.md Line 40 in a070501
|
Reverted changes to template files in the BlazorWeb-CSharp directory. The templates now use |
src/Middleware/Diagnostics/src/StatusCodePage/StatusCodePagesExtensions.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: javiercn <[email protected]>
I don't get it. If we don't change templates, they fail with
If we change them, they fail with
Locally I'm hitting #62746. We cannot merge until I figure out how to solve it. edit: on my machine all the tests are passing. Trying to find a reason for CI to behave differently. |
@copilot remove line "app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);" from src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Program.Main.cs and src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Program.cs. We're having failures in both cases: if we update the templates and when we won't do that. This line should be added in a follow-up PR when the template sdk that we're using for |
Co-authored-by: ilonatommy <[email protected]>
Removed the UseStatusCodePagesWithReExecute calls from both template files as requested. This will prevent CI failures until the template SDK is updated with the new parameter in a follow-up PR. |
This PR implements the approved API proposal to add support for creating DI scopes when re-executing requests in StatusCodePages middleware.
Changes Made
API Surface Changes
StatusCodePagesOptions:
CreateScopeForErrors
→CreateScopeForStatusCodePages
propertyfalse
to maintain existing behaviorStatusCodePagesExtensions:
UseStatusCodePagesWithReExecute(string, string?)
to remove default parameterUseStatusCodePagesWithReExecute(string, string? = null, bool createScopeForStatusCodePages = false)
Usage Examples
Implementation Details
CreateHandler
method to use the new property nameBenefits
This change allows error handling middleware to run in a fresh DI scope, which is important for scenarios where:
CreateScopeForErrors
functionality inExceptionHandler
The API follows the same pattern as
ExceptionHandlerOptions.CreateScopeForErrors
for consistency.Fixes #62408.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.