Previous tip (Grab values from the query string) Next tip (Modify the HTML Head from a component) >>

Modify the query string

Use the .GetUriWithQueryParameter method on Navigation Manager to get the current URI with modified query string parameters.

You can navigate to the modified URI using NavigateTo.

Set multiple values at once using the .GetUriWithQueryParameters method.

@inject NavigationManager NavMan
...
@code {
[Parameter]
[SupplyParameterFromQuery]
public bool InStock { get; set; }
private void FindNotInStock()
{
var newUri = NavMan
.GetUriWithQueryParameter(
"instock", false);
NavMan.NavigateTo(newUri);
}
}