-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add NotFound method in NavigationManager for interactive and static rendering
#60752
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
Merged
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e92baae
Interactive NotFound event + SSR status code.
ilonatommy d48e2bf
Remove circular DI, pass renderer on initialization instead.
ilonatommy 3a7178d
Interactive NotFound tests.
ilonatommy 580b8be
Server test.
ilonatommy 58b6895
Cleanup.
ilonatommy a5ca308
Fix the API Analyzer bug.
ilonatommy b3b4e18
Limit the added APIs by removing event cancellation.
ilonatommy 758448e
Formatting + rename.
ilonatommy ca379eb
Formatting.
ilonatommy ef94091
Address copilot's feedback.
ilonatommy bfa8145
Feedback.
ilonatommy 21314b6
Feedback - server
ilonatommy 73f0e07
Fix event registration.
ilonatommy 1877327
Trying to fix the build error.
ilonatommy 3cdd10f
Nullabillity
ilonatommy bf6041b
Limit public API.
ilonatommy 6ce7bda
Dispose renderer + move tests.
ilonatommy 95ac585
Merge remote-tracking branch 'upstream/main' into fix-45654
ilonatommy c89cd57
@javiercn's fixes
ilonatommy 2c380ea
Feedback - rename + comment.
ilonatommy aa1b149
Merge remote-tracking branch 'upstream/main' into fix-45654
ilonatommy 3ed2b74
Fix ailing test - do not subscribe if manager is not initialized.
ilonatommy d8751ab
Change the test setup instead changing the NavigationManager.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.AspNetCore.Components; | ||
|
|
||
| /// <summary> | ||
| /// An interface for EndpointHtmlRenderer implementations that allows NavigationManagers call renderer's methods | ||
| /// </summary> | ||
| public interface IEndpointHtmlRenderer | ||
| { | ||
| /// <summary> | ||
| /// Sets the html response to 404 Not Found. | ||
| /// </summary> | ||
| void SetNotFoundResponse(); | ||
| } |
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
20 changes: 20 additions & 0 deletions
20
src/Components/Components/src/NotFoundRenderingException.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.AspNetCore.Components; | ||
|
|
||
| /// <summary> | ||
| /// Exception thrown when an <see cref="NavigationManager"/> is not able to render not found page. | ||
| /// </summary> | ||
| public class NotFoundRenderingException : Exception | ||
| { | ||
| /// <summary> | ||
| /// Creates a new instance of <see cref="NotFoundRenderingException"/>. | ||
| /// </summary> | ||
| /// <param name="message">The exception message.</param> | ||
| /// <param name="innerException">The inner exception.</param> | ||
| public NotFoundRenderingException(string message, Exception innerException) | ||
| : base(message, innerException) | ||
| { | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,17 @@ | ||
| #nullable enable | ||
| Microsoft.AspNetCore.Components.IEndpointHtmlRenderer | ||
| Microsoft.AspNetCore.Components.IEndpointHtmlRenderer.SetNotFoundResponse() -> void | ||
| Microsoft.AspNetCore.Components.NavigationManager.NotFoundEvent -> System.EventHandler<System.EventArgs!>! | ||
| Microsoft.AspNetCore.Components.NavigationManager.NotifyNotFound() -> void | ||
| Microsoft.AspNetCore.Components.NavigationManager.NotifyNotFoundAsync() -> System.Threading.Tasks.ValueTask<bool> | ||
| Microsoft.AspNetCore.Components.NotFoundRenderingException | ||
| Microsoft.AspNetCore.Components.NotFoundRenderingException.NotFoundRenderingException(string! message, System.Exception! innerException) -> void | ||
| Microsoft.AspNetCore.Components.Routing.IHostEnvironmentNavigationManager.Initialize(string! baseUri, string! uri, Microsoft.AspNetCore.Components.IEndpointHtmlRenderer! renderer) -> void | ||
| Microsoft.AspNetCore.Components.Routing.NotFoundContext | ||
| Microsoft.AspNetCore.Components.Routing.NotFoundContext.CancellationToken.get -> System.Threading.CancellationToken | ||
| Microsoft.AspNetCore.Components.Routing.NotFoundContext.CancellationToken.init -> void | ||
| Microsoft.AspNetCore.Components.Routing.NotFoundContext.NotFoundContext() -> void | ||
| Microsoft.AspNetCore.Components.Routing.NotFoundContext.PreventRendering() -> void | ||
| virtual Microsoft.AspNetCore.Components.NavigationManager.HandleNotFoundHandlerException(System.Exception! ex, Microsoft.AspNetCore.Components.Routing.NotFoundContext! context) -> void | ||
| virtual Microsoft.AspNetCore.Components.NavigationManager.NotFound() -> void | ||
| virtual Microsoft.AspNetCore.Components.NavigationManager.NotFoundCore() -> void |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.AspNetCore.Components.Routing; | ||
|
|
||
| /// <summary> | ||
| /// Contains context for a change to the browser's current location. | ||
| /// </summary> | ||
| public sealed class NotFoundContext | ||
| { | ||
| internal bool DidPreventRendering { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets a <see cref="System.Threading.CancellationToken"/> that can be used to determine if this navigation was canceled | ||
| /// (for example, because the user has triggered a different navigation). | ||
| /// </summary> | ||
| public CancellationToken CancellationToken { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Prevents this navigation from continuing. | ||
| /// </summary> | ||
| public void PreventRendering() | ||
| { | ||
| DidPreventRendering = true; | ||
| } | ||
|
|
||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.