Skip to content

Improve 'GetUriWithQueryParameter' examples#37158

Open
guardrex wants to merge 2 commits into
mainfrom
guardrex/add-navigateto-call-to-examples
Open

Improve 'GetUriWithQueryParameter' examples#37158
guardrex wants to merge 2 commits into
mainfrom
guardrex/add-navigateto-call-to-examples

Conversation

@guardrex
Copy link
Copy Markdown
Collaborator

@guardrex guardrex commented May 15, 2026

Fixes #37157

Wade, Tom ... Just need one review to get this in.

Noticed this while working with Daria on the QuickGrid PR, where we needed to use GetUriWithQueryParameter in a QuickGrid example.

I'd like to do two things here to improve this batch of examples in the Navigation article ...

  • Add a NOTE at the top of the GetUriWithQueryParameter examples that Navigation in the examples is an injected NavigationManager. After that NOTE, all of the examples can just be C# calls with a shorter code display.
  • Add the NavigateTo calls to the GetUriWithQueryParameter examples to make them fully functional calls. GetUriWithQueryParameter by itself just gets a URI.

WRT Copilot's recommendation to state Dictionary<string, object?> for the remark about GetUriWithQueryParameters calls, that's true. IReadOnlyDictionary isn't the best API to specify because (IIRC) the method signature is for IReadOnlyDictionary ... that's why it was there. If I had focused the sentences on something about the method signature, that probably would've been fine. However, Copilot is correct ... it should indicate what the developer is passing.


Internal previews

📄 File 🔗 Preview link
aspnetcore/blazor/fundamentals/navigation.md aspnetcore/blazor/fundamentals/navigation

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Blazor navigation documentation to make the GetUriWithQueryParameter(s) guidance easier to follow by clarifying the Navigation instance used in examples and showing fully functional navigation calls.

Changes:

  • Added a NOTE that Navigation refers to an injected NavigationManager, with an @inject snippet.
  • Updated GetUriWithQueryParameter(s) examples to pass the generated URI to Navigation.NavigateTo(...) so the examples perform navigation.
  • Reformatted several examples as shorter C# call snippets.
Comments suppressed due to low confidence (2)

aspnetcore/blazor/fundamentals/navigation.md:994

  • The text under “For the preceding example” describes a returned string (“A string is returned…”), but the preceding code sample now calls NavigateTo(...) (which doesn’t return a URI). Either adjust the prose to refer specifically to the inner GetUriWithQueryParameter call, or revise the sample to capture the returned URI before calling NavigateTo.
```csharp
Navigation.NavigateTo(Navigation.GetUriWithQueryParameter("{NAME}", {VALUE}));

For the preceding example:

  • The {NAME} placeholder specifies the query parameter name. The {VALUE} placeholder specifies the value as a supported type. Supported types are listed later in this section.
  • A string is returned equal to the current URL with a single parameter:
    • Added if the query parameter name doesn't exist in the current URL.
    • Updated to the value provided if the query parameter exists in the current URL.
    • Removed if the type of the provided value is nullable and the value is null.
**aspnetcore/blazor/fundamentals/navigation.md:1014**
* Same as above: the bullet list repeats the `{PARAMETERS}` placeholder type as `IReadOnlyDictionary<string, object>`, which conflicts with the `object?` usage in the examples (null values). Update this to `IReadOnlyDictionary<string, object?>` for consistency.
  • The {URI} placeholder is the URI with or without a query string.
  • The {PARAMETERS} placeholder is an IReadOnlyDictionary<string, object>.
</details>

Comment thread aspnetcore/blazor/fundamentals/navigation.md
Comment thread aspnetcore/blazor/fundamentals/navigation.md
Comment thread aspnetcore/blazor/fundamentals/navigation.md
@guardrex guardrex requested review from tdykstra and wadepickett May 15, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the NavigateTo call for query string method guidance

2 participants