🎓 All Courses | 📚 Blazor WASM Syllabus
Stickipedia University
📋 Study this course on TaskLoco

Query parameters allow passing data through the URL — like /search?term=blazor&page=2. Blazor supports reading query parameters directly as component parameters.

Reading Query Parameters

@page "/search"

<h1>Search: @Term</h1>

@code {
    [Parameter, SupplyParameterFromQuery]
    public string? Term { get; set; }

    [Parameter, SupplyParameterFromQuery(Name = "page")]
    public int Page { get; set; } = 1;
}

Building URLs with Query Strings

@inject NavigationManager Nav

private void Search(string term)
{
    var uri = Nav.GetUriWithQueryParameters(
        Nav.Uri,
        new Dictionary<string, object?> {
            ["term"] = term,
            ["page"] = 1
        });
    Nav.NavigateTo(uri);
}

Best Practices

  • Use query params for shareable bookmarkable state: search terms, filters, pagination
  • Use component state or AppState for transient UI state that should not persist in the URL

YouTube • Top 10
Blazor WASM: Query Parameters
Tap to Watch ›
📸
Google Images • Top 10
Blazor WASM: Query Parameters
Tap to View ›

Reference:

Wikipedia: Query String

image for linkhttps://en.wikipedia.org/wiki/Query_string

📚 Blazor WASM — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT