diff --git a/src/Components/Components/src/NavigationManager.cs b/src/Components/Components/src/NavigationManager.cs index 1c8c8e01563f..d721133dd02d 100644 --- a/src/Components/Components/src/NavigationManager.cs +++ b/src/Components/Components/src/NavigationManager.cs @@ -38,7 +38,7 @@ public event EventHandler LocationChanged /// /// An event that fires when the page is not found. /// - public event EventHandler NotFoundEvent + public event EventHandler OnNotFound { add { @@ -52,7 +52,7 @@ public event EventHandler NotFoundEvent } } - private EventHandler? _notFound; + private EventHandler? _notFound; // For the baseUri it's worth storing as a System.Uri so we can do operations // on that type. System.Uri gives us access to the original string anyway. @@ -199,11 +199,11 @@ public virtual void Refresh(bool forceReload = false) /// /// Handles setting the NotFound state. /// - public virtual void NotFound() => NotFoundCore(); + public void NotFound() => NotFoundCore(); private void NotFoundCore() { - _notFound?.Invoke(this, new EventArgs()); + _notFound?.Invoke(this, new NotFoundEventArgs()); } /// diff --git a/src/Components/Components/src/PublicAPI.Unshipped.txt b/src/Components/Components/src/PublicAPI.Unshipped.txt index 441f46ffe210..5b2d8d1cec3f 100644 --- a/src/Components/Components/src/PublicAPI.Unshipped.txt +++ b/src/Components/Components/src/PublicAPI.Unshipped.txt @@ -1,6 +1,8 @@ #nullable enable -Microsoft.AspNetCore.Components.NavigationManager.NotFoundEvent -> System.EventHandler! -virtual Microsoft.AspNetCore.Components.NavigationManager.NotFound() -> void +Microsoft.AspNetCore.Components.NavigationManager.OnNotFound -> System.EventHandler! +Microsoft.AspNetCore.Components.NavigationManager.NotFound() -> void +Microsoft.AspNetCore.Components.Routing.NotFoundEventArgs +Microsoft.AspNetCore.Components.Routing.NotFoundEventArgs.NotFoundEventArgs() -> void Microsoft.AspNetCore.Components.Infrastructure.ComponentStatePersistenceManager.ComponentStatePersistenceManager(Microsoft.Extensions.Logging.ILogger! logger, System.IServiceProvider! serviceProvider) -> void Microsoft.AspNetCore.Components.Infrastructure.ComponentStatePersistenceManager.SetPlatformRenderMode(Microsoft.AspNetCore.Components.IComponentRenderMode! renderMode) -> void Microsoft.AspNetCore.Components.Infrastructure.RegisterPersistentComponentStateServiceCollectionExtensions diff --git a/src/Components/Components/src/Routing/NotFoundEventArgs.cs b/src/Components/Components/src/Routing/NotFoundEventArgs.cs new file mode 100644 index 000000000000..637bfd442b70 --- /dev/null +++ b/src/Components/Components/src/Routing/NotFoundEventArgs.cs @@ -0,0 +1,16 @@ +// 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; + +/// +/// for . +/// +public sealed class NotFoundEventArgs : EventArgs +{ + /// + /// Initializes a new instance of . + /// + public NotFoundEventArgs() + { } +} diff --git a/src/Components/Components/src/Routing/Router.cs b/src/Components/Components/src/Routing/Router.cs index f27226d492a9..7eabfa828aa4 100644 --- a/src/Components/Components/src/Routing/Router.cs +++ b/src/Components/Components/src/Routing/Router.cs @@ -105,7 +105,7 @@ public void Attach(RenderHandle renderHandle) _baseUri = NavigationManager.BaseUri; _locationAbsolute = NavigationManager.Uri; NavigationManager.LocationChanged += OnLocationChanged; - NavigationManager.NotFoundEvent += OnNotFound; + NavigationManager.OnNotFound += OnNotFound; RoutingStateProvider = ServiceProvider.GetService(); if (HotReloadManager.Default.MetadataUpdateSupported) @@ -147,7 +147,7 @@ public async Task SetParametersAsync(ParameterView parameters) public void Dispose() { NavigationManager.LocationChanged -= OnLocationChanged; - NavigationManager.NotFoundEvent -= OnNotFound; + NavigationManager.OnNotFound -= OnNotFound; if (HotReloadManager.Default.MetadataUpdateSupported) { HotReloadManager.Default.OnDeltaApplied -= ClearRouteCaches; diff --git a/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs b/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs index 428e84d3ead5..965858d807c0 100644 --- a/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs +++ b/src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs @@ -83,7 +83,7 @@ internal async Task InitializeStandardComponentServicesAsync( if (navigationManager != null) { - navigationManager.NotFoundEvent += SetNotFoundResponse; + navigationManager.OnNotFound += SetNotFoundResponse; } var authenticationStateProvider = httpContext.RequestServices.GetService();