Skip to content

[Blazor] SetParametersAsync called multiple times with the same non-mutable parametersΒ #63314

@georgehemmings

Description

@georgehemmings

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a Blazor component/page with a Route and Query String (SupplyParameterFromQuery) parameter. When both values change SetParametersAsync is called twice - the parameter/property values are identical on each call.

[Parameter]
public string Name { get; set; }

[Parameter]
[SupplyParameterFromQuery]
public int Count { get; set; }

Expected Behavior

I'd expect SetParametersAsync to be called once as the types of the parameters are non-mutable.
If both parameters are query parameters then SetParametersAsync is only called once.

Steps To Reproduce

Repro project: https://github.com/georgehemmings/BlazorDuplicateSetParams
The project is the a standard Blazor Server template with modifications to Counter.razor

Go to: https://localhost:7243/counter/A?Count=1000

Click "Counter A Add 1"
Then click "Counter B Add 1"

Observe "Current count" changes from 1000 to 1 as expected.
However note setParametersAsyncCalledCount jumps from1 to 3.
Alternatively place a break point on Line 56 of Counter.razor and observe that the parameters are the same for each execution.

Clicking either button repeated only increases setParametersAsyncCalledCount by 1. It's only when switching between the buttons that SetPamatersAsync is called twice.

Exceptions (if any)

No response

.NET Version

No response

Anything else?

.NET 9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions