NavigationManagerExtensions.GetUriWithHash(NavigationManager, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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>