Share via


NavigationManagerExtensions.GetUriWithHash(NavigationManager, String) Method

Definition

Returns a URI constructed from Uri with a hash added, updated, or removed.

public static string GetUriWithHash(this Microsoft.AspNetCore.Components.NavigationManager navigationManager, string hash);
static member GetUriWithHash : Microsoft.AspNetCore.Components.NavigationManager * string -> string
<Extension()>
Public Function GetUriWithHash (navigationManager As NavigationManager, hash As String) As String

Parameters

navigationManager
NavigationManager

The NavigationManager.

hash
String

The hash string. If empty, the hash will be removed from the URI.

Returns

The URI with the specified hash.

Remarks

If hash does not start with #, then # will be prepended.

This method is useful when the document's baseURI differs from its location, such as when a <base> element is used, since relative hash URLs are resolved relative to the baseURI.

@inject NavigationManager Nav
<a href="@Nav.GetUriWithHash("section1")">Go to section 1</a>

Applies to