-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Support NotFound
content rendering for a custom Router
#62635
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the NotFound event handling in Blazor components to better support custom routers and fix issues with async operations. The main changes include removing the NotFound
fragment support, moving 404 handling from the endpoint renderer to the endpoint invoker, and improving the communication between routers and renderers about NotFound event handling.
Key Changes:
- Moves NotFound event handling from endpoint renderer to endpoint invoker for better async operation support
- Refactors
NotFoundEventArgs
to use a settablePath
property to indicate router handling - Updates test infrastructure to better test async NotFound scenarios and custom router behavior
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
NotFoundEventArgs.cs | Converts constructor parameter to settable property for router communication |
Router.cs | Updates to set Path property when handling NotFound events |
NavigationManager.cs | Simplifies NotFound event triggering with reusable event args |
RazorComponentEndpointInvoker.cs | Moves NotFound handling logic from renderer to invoker |
EndpointHtmlRenderer.cs | Refactors NotFound response handling into separate methods |
CustomRouter.cs | Adds new custom router implementation for testing |
Test files | Updates test infrastructure and parameter names for better async testing |
src/Components/test/testassets/Components.TestServer/RazorComponents/CustomRouter.cs
Outdated
Show resolved
Hide resolved
src/Components/test/testassets/Components.TestServer/RazorComponents/CustomRouter.cs
Show resolved
Hide resolved
…is not nullable. Use if-else instead.
This PR:
NotFound
fragment - it cannot be rendered usingNavigationManager.NotFound()
. UPDATE DOCSNotFound
event after async operations.NotFound
event without blazor defaultRouter
component.Implementation description
SetNotFoundResponseAsync
withhttpContext.Response.HasStarted
condition into 2 separate methods that are called before and after response started, if 404 event was triggered.Router
handled rendering ofNotFoundPage
by setting thePath
inNotFoundEventArgs
. If that property is not set, router treats the request as not handled, cleans the response and avoids flushing in order to allow re-execution middleware act.Fixes #62367, Fixes #62469, Fixes #62153