-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Unify the UX of template projects on navigation to non-existing page #62067
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?
Unify the UX of template projects on navigation to non-existing page #62067
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
The PR ensures consistent re-execution behavior for navigation to non-existing pages across Blazor templates by configuring status code middleware and adding end-to-end tests.
- Added
UseStatusCodePagesWithReExecute
middleware in both Program entrypoints to route 404s to/not-found
. - Introduced shared test components and organized NotFound tests for interactive, SSR, and streaming scenarios.
- Refactored startup classes to extract endpoint configuration and added re-execution branches in non-interactive pipelines.
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/ProjectTemplates/Web.ProjectTemplates/.../Program.cs | Added status code pages middleware for 404 handling |
src/ProjectTemplates/Web.ProjectTemplates/.../Program.Main.cs | Duplicated middleware call in Main variant |
src/Components/test/testassets/Components.WasmMinimal/RenderModeHelper.cs | Removed namespace, leaving helper in the global namespace |
src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs | Made ConfigureSubdirPipeline private and extracted ConfigureEndpoints |
src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsNoInteractivityStartup.cs | Added mapped re-execution branch under /subdir/reexecution |
src/Components/test/E2ETest/ServerRenderingTests/NoInteractivityTest.cs & InteractivityTest.cs | New E2E theories for programmatic, link, and browser navigation |
Comments suppressed due to low confidence (3)
src/Components/test/testassets/Components.WasmMinimal/RenderModeHelper.cs:8
- RenderModeHelper is now in the global namespace after removing the original namespace; consider adding an appropriate namespace to keep test helpers organized.
public static class RenderModeHelper
src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs:89
- Changing ConfigureSubdirPipeline from protected virtual to private removes the ability for subclasses to override it; consider retaining protected visibility or providing a new protected hook.
private void ConfigureSubdirPipeline(IApplicationBuilder app, IWebHostEnvironment env)
src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsNoInteractivityStartup.cs:66
- It looks like a closing brace for the inner
app.Map
block was removed, which may lead to mismatched braces and a compile error. Please verify block boundaries and restore the missing brace.
}
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Program.cs
Show resolved
Hide resolved
Instead of requiring re-executing the pipeline, could the Router component handle rendering the Not Found page instead for these cases similar to how things work when the Router is interactive? |
Do template tests operate on older version of framework?
aspnetcore/src/Middleware/Diagnostics/src/StatusCodePage/StatusCodePagesExtensions.cs Line 178 in c5d6996
|
You don't get to even execute Blazor if you have a 404 because someone introduced the wrong URL in the address bar or click a link to an inexistent location. The router will only work for cases where you explicitly invoke |
Templates use re-execution
Before this PR navigating away to non-existing page by:
NavigationManager.NavigateTo(nonExistingPath)
was inconsistent with
Navigation.NotFound()
behavior. See the "before" video:before.mp4
Now, all of them are behaving the same way, see "after" video:
After.mp4
Description
NotFound
tests. There is enough of them to pack them to a separate directory.Navigation.NotFound()
. Previously addedNotFound.razor
page was not used in the template. In case the user started calling newNotFound
method, they would see a different behavior than in the cases of navigating away to non-existing url. It was reported as inconsistent UX by @danroth27.