diff --git a/src/Components/Components/src/NavigationManager.cs b/src/Components/Components/src/NavigationManager.cs
index e5752e669a38..a363a3dbca12 100644
--- a/src/Components/Components/src/NavigationManager.cs
+++ b/src/Components/Components/src/NavigationManager.cs
@@ -84,18 +84,41 @@ protected set
}
}
+ ///
+ /// Navigates to the specified URI.
+ ///
+ /// The destination URI. This can be absolute, or relative to the base URI
+ /// (as returned by ).
+ public void NavigateTo(string uri)
+ => NavigateTo(uri, forceLoad: false);
+
///
/// Navigates to the specified URI.
///
/// The destination URI. This can be absolute, or relative to the base URI
/// (as returned by ).
/// If true, bypasses client-side routing and forces the browser to load the new page from the server, whether or not the URI would normally be handled by the client-side router.
- public void NavigateTo(string uri, bool forceLoad = false)
+ public void NavigateTo(string uri, bool forceLoad)
{
AssertInitialized();
+
+ // For back-compatibility, we must call the (string, bool) overload of NavigateToCore from here,
+ // because that's the only overload guaranteed to be implemented in subclasses.
NavigateToCore(uri, forceLoad);
}
+ ///
+ /// Navigates to the specified URI.
+ ///
+ /// The destination URI. This can be absolute, or relative to the base URI
+ /// (as returned by ).
+ /// Provides additional .
+ public void NavigateTo(string uri, NavigationOptions options)
+ {
+ AssertInitialized();
+ NavigateToCore(uri, options);
+ }
+
///
/// Navigates to the specified URI.
///
@@ -104,6 +127,15 @@ public void NavigateTo(string uri, bool forceLoad = false)
/// If true, bypasses client-side routing and forces the browser to load the new page from the server, whether or not the URI would normally be handled by the client-side router.
protected abstract void NavigateToCore(string uri, bool forceLoad);
+ ///
+ /// Navigates to the specified URI.
+ ///
+ /// The destination URI. This can be absolute, or relative to the base URI
+ /// (as returned by ).
+ /// Provides additional .
+ protected virtual void NavigateToCore(string uri, NavigationOptions options) =>
+ throw new NotImplementedException($"The type {GetType().FullName} does not support supplying {nameof(NavigationOptions)}. To add support, that type should override {nameof(NavigateToCore)}(string uri, {nameof(NavigationOptions)} options).");
+
///
/// Called to initialize BaseURI and current URI before these values are used for the first time.
/// Override and call this method to dynamically calculate these values.
diff --git a/src/Components/Components/src/NavigationOptions.cs b/src/Components/Components/src/NavigationOptions.cs
new file mode 100644
index 000000000000..1a45b0461570
--- /dev/null
+++ b/src/Components/Components/src/NavigationOptions.cs
@@ -0,0 +1,27 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+
+namespace Microsoft.AspNetCore.Components
+{
+ ///
+ /// Additional options for navigating to another URI
+ ///
+ [Flags]
+ public enum NavigationOptions
+ {
+ ///
+ /// Use default options
+ ///
+ None = 0,
+ ///
+ /// Bypasses client-side routing and forces the browser to load the new page from the server, whether or not the URI would normally be handled by the client-side router.
+ ///
+ ForceLoad = 1,
+ ///
+ /// Indicates that the current history entry should be replaced, instead of pushing the new uri onto the browser history stack.
+ ///
+ ReplaceHistoryEntry = 2
+ }
+}
diff --git a/src/Components/Components/src/PublicAPI.Unshipped.txt b/src/Components/Components/src/PublicAPI.Unshipped.txt
index 3acbf2de6886..07179c724a61 100644
--- a/src/Components/Components/src/PublicAPI.Unshipped.txt
+++ b/src/Components/Components/src/PublicAPI.Unshipped.txt
@@ -7,5 +7,14 @@ Microsoft.AspNetCore.Components.DynamicComponent.Parameters.set -> void
Microsoft.AspNetCore.Components.DynamicComponent.SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Components.DynamicComponent.Type.get -> System.Type!
Microsoft.AspNetCore.Components.DynamicComponent.Type.set -> void
+Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(string! uri) -> void
+Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(string! uri, Microsoft.AspNetCore.Components.NavigationOptions options) -> void
+*REMOVED*Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(string! uri, bool forceLoad = false) -> void
+Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(string! uri, bool forceLoad) -> void
+Microsoft.AspNetCore.Components.NavigationOptions
+Microsoft.AspNetCore.Components.NavigationOptions.ForceLoad = 1 -> Microsoft.AspNetCore.Components.NavigationOptions
+Microsoft.AspNetCore.Components.NavigationOptions.None = 0 -> Microsoft.AspNetCore.Components.NavigationOptions
+Microsoft.AspNetCore.Components.NavigationOptions.ReplaceHistoryEntry = 2 -> Microsoft.AspNetCore.Components.NavigationOptions
static Microsoft.AspNetCore.Components.ParameterView.FromDictionary(System.Collections.Generic.IDictionary! parameters) -> Microsoft.AspNetCore.Components.ParameterView
+virtual Microsoft.AspNetCore.Components.NavigationManager.NavigateToCore(string! uri, Microsoft.AspNetCore.Components.NavigationOptions options) -> void
virtual Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(ulong eventHandlerId, Microsoft.AspNetCore.Components.RenderTree.EventFieldInfo? fieldInfo, System.EventArgs! eventArgs) -> System.Threading.Tasks.Task!
diff --git a/src/Components/Server/src/Circuits/RemoteNavigationManager.cs b/src/Components/Server/src/Circuits/RemoteNavigationManager.cs
index b57130c29a30..2b11aced17b8 100644
--- a/src/Components/Server/src/Circuits/RemoteNavigationManager.cs
+++ b/src/Components/Server/src/Circuits/RemoteNavigationManager.cs
@@ -67,28 +67,35 @@ public void NotifyLocationChanged(string uri, bool intercepted)
///
protected override void NavigateToCore(string uri, bool forceLoad)
{
- Log.RequestingNavigation(_logger, uri, forceLoad);
+ NavigateToCore(uri, forceLoad ? NavigationOptions.ForceLoad : NavigationOptions.None);
+ }
+
+ ///
+ protected override void NavigateToCore(string uri, NavigationOptions options)
+ {
+ Log.RequestingNavigation(_logger, uri, options);
if (_jsRuntime == null)
{
var absoluteUriString = ToAbsoluteUri(uri).ToString();
throw new NavigationException(absoluteUriString);
}
-
- _jsRuntime.InvokeAsync