-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add NotFoundPage
to Router
#60970
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
Merged
+567
−73
Merged
Add NotFoundPage
to Router
#60970
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
11956ec
Add `NotFoundPage`.
ilonatommy 216ec31
Fix rebase error.
ilonatommy 3168993
Draft of template changes.
ilonatommy 067cfd2
Typo errors.
ilonatommy 6d22aad
NavigationManager is not needed for SSR.
ilonatommy 6ea7082
Add BOM to new teamplate files.
ilonatommy 25e8e66
Move instead of exclude.
ilonatommy 1060b4d
Clean up, fix tests.
ilonatommy fc696c3
Fix
ilonatommy 44e7d8e
Apply smallest possible changes to templates.
ilonatommy ae68011
Missing changes to baseline.
ilonatommy 39deb2b
Prevent throwing.
ilonatommy 6b620d5
Fix configurations without global router.
ilonatommy 6876252
Merge branch 'main' into fix-58815
ilonatommy 74e3eae
Fix "response started" scenarios.
ilonatommy e10b90c
Fix template tests.
ilonatommy b660d19
Fix baseline tests.
ilonatommy d566c4b
This is a draft of uneffective `UseStatusCodePagesWithReExecute`, cc …
ilonatommy d41bd5b
Update.
ilonatommy 005f217
Fix reexecution mechanism.
ilonatommy 8c7b6d2
Fix public API.
ilonatommy f876e4d
Args order.
ilonatommy 8744e8b
Draft of test.
ilonatommy aee53a9
Per page interactivity test.
ilonatommy de91b4b
Revert unnecessary change.
ilonatommy 7e7f1fe
Typo: we want to stop only if status pages are on.
ilonatommy 6a10062
Remove comments.
ilonatommy 5518812
Fix tests.
ilonatommy c8eb629
Feedback.
ilonatommy 66b563c
Feedback.
ilonatommy 1da92f9
Failing test - re-executed without a reason.
ilonatommy b7775ef
Add streaming test after response started.
ilonatommy cb32f94
Test SSR with no interactivity.
ilonatommy 8273758
Stop the renderer regardless of `Response.HasStarted`.
ilonatommy c31812c
Feedback: not checking status code works as well.
ilonatommy b162946
Feedback: improve handling streaming-in-process case.
ilonatommy f57b0b7
Merge branch 'main' into fix-58815
ilonatommy 3e77c62
Throw on NotFound without global router.
ilonatommy d612592
Use `IStatusCodeReExecuteFeature`.
ilonatommy cd5dffa
Unify "fallback" pages - check for titles only.
ilonatommy b416805
Fix early return condition.
ilonatommy fc63304
Merge branch 'main' into fix-58815
ilonatommy c0e7f86
Feedback.
ilonatommy 124b470
Merge branch 'main' into fix-58815
ilonatommy ebdf9a9
No-op instead of exception.
ilonatommy fc49fe6
Solve merge conflict: hard stop in redirection and deferred stop in 404.
ilonatommy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think the interface we are looking for is
IStatusCodeReExecuteFeature
notIStatusCodePagesFeature
. The latter is added all the time to the middleware, while the first one is only added by the handler when it's dealing with the re-execution code path, which I think is what we want (and is the equivalent of isErrorHandler)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.
This complicates the logic a bit. We need a way to avoid writing the response (so return from
RenderComponentCore
method before flushing) if we expect re-execution. By "expect" re-executon I mean: status code page was set, we used to have a 200 but now we have 404. At the place where we would like to detect it,IStatusCodeReExecuteFeature
is unset and we have no way of preventing starting the response.We could set
IStatusCodeReExecuteFeature
for in the handler subscribed toOnNotFound
event: inSetNotFoundResponseAsync
. This forces us to add<Reference Include="Microsoft.AspNetCore.Diagnostics" />
toMicrosoft.AspNetCore.Components.Endpoints.csproj
. Is this acceptable?Otherwise, we will return too early to handle re-execution, again this condition:
aspnetcore/src/Middleware/Diagnostics/src/StatusCodePage/StatusCodePagesMiddleware.cs
Line 67 in 55a1ae7
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.
Relying on
IStatusCodeReExecuteFeature
fails - the result is that we always flush the response and we never have a chance to re-execute.The problem here is that we would like to detect the page that is going to re-execute, to prevent writing to its contents, not a page that already was re-executed.
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.
In error handler we don't have such a problem (we don't have to detect to return early) because the thrown exception does it for us. We never execute any code after
RenderEndpointComponent
in EH case. For 404 we have to return early based on a condition.The most reasonable is probably
IStatusCodePagesFeature->set
&IStatusCodeReExecuteFeature->unset
&responseCode->404
.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.
I don't fully follow, but I don't think we need to block on this