NavigationManagerExtensions Class

Extension methods for NavigationManager to work with query string parameters.

public static class NavigationManagerExtensions

Methods

NameDescription
GetQueryStringParameterValue(NavigationManager, string)Gets the first value of a query string parameter from the current URL.
GetQueryStringParameterValues(NavigationManager, string)Gets all values of a query string parameter from the current URL.
UpdateUrlUsingParameters(NavigationManager, IComponent, bool)Updates the current URL with query string parameters from component properties marked with SupplyParameterFromQueryAttribute.

GetQueryStringParameterValue(NavigationManager, string)

NavigationManagerExtensions.cs

Gets the first value of a query string parameter from the current URL.

public static string? GetQueryStringParameterValue(this NavigationManager navigationManager, string parameterName)

Parameters

navigationManager NavigationManager
The navigation manager.
parameterName string
The name of the query string parameter.

Returns

string? The first value of the parameter, or null if the parameter is not found.

GetQueryStringParameterValues(NavigationManager, string)

NavigationManagerExtensions.cs

Gets all values of a query string parameter from the current URL.

public static IReadOnlyList<string> GetQueryStringParameterValues(this NavigationManager navigationManager, string parameterName)

Parameters

navigationManager NavigationManager
The navigation manager.
parameterName string
The name of the query string parameter.

Returns

IReadOnlyList<string> A read-only list of all values for the parameter, or an empty list if the parameter is not found.

UpdateUrlUsingParameters(NavigationManager, IComponent, bool)

NavigationManagerExtensions.cs

Updates the current URL with query string parameters from component properties marked with SupplyParameterFromQueryAttribute.

public static void UpdateUrlUsingParameters(this NavigationManager navigationManager, IComponent component, bool replaceHistory = false)

Parameters

navigationManager NavigationManager
The navigation manager.
component IComponent
The component whose properties should be used to update the query string.
replaceHistory bool
Whether to replace the current history entry instead of adding a new one.