dotnet/AspNetCore.Docs · error · ArgumentException

Unknown parameter: {parameter.Name}

Error message

Unknown parameter: {parameter.Name}

What it means

ArgumentException thrown in a manual override of ComponentBase.SetParametersAsync when iterating ParameterView and encountering a parameter name not handled by the explicit switch (MessageId, Text, TextChanged, CurrentTheme). The default case rejects unknown parameters to keep the component's parameter surface explicit and to surface typos or stale bindings early.

Source

Thrown at aspnetcore/blazor/performance/rendering.md:323

    {
        foreach (var parameter in parameters)
        {
            switch (parameter.Name)
            {
                case nameof(MessageId):
                    MessageId = (int)parameter.Value;
                    break;
                case nameof(Text):
                    Text = (string)parameter.Value;
                    break;
                case nameof(TextChanged):
                    TextChanged = (EventCallback<string>)parameter.Value;
                    break;
                case nameof(CurrentTheme):
                    CurrentTheme = (Theme)parameter.Value;
                    break;
                default:
                    throw new ArgumentException($"Unknown parameter: {parameter.Name}");
            }
        }

        return base.SetParametersAsync(ParameterView.Empty);
    }
}
```

In the preceding code, returning the base class <xref:Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync%2A> runs the normal lifecycle method without assigning parameters again.

:::moniker range=">= aspnetcore-8.0"

As you can see in the preceding code, overriding <xref:Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync%2A> and supplying custom logic is complicated and laborious, so we don't generally recommend adopting this approach. In extreme cases, the approach can yield a small rendering improvement, typically under ~10% even at 10,000+ component instances when targeting .NET 10. The potential gains are smaller in later releases because reflection-based parameter assignment is optimized. Only consider this approach in the extreme scenarios listed earlier in this section and benchmark first&mdash;the savings are usually dwarfed by other costs, for example, the SignalR [diff (DOM edits)](xref:blazor/components/lifecycle#lifecycle-events) transport for Interactive Server.

:::moniker-end

:::moniker range="< aspnetcore-8.0"

View on GitHub (pinned to c67a80103a)

Solutions

  1. Compare the bound attribute names against the component's declared parameters and remove or correct any mismatch.
  2. If the parameter is intentionally optional/unknown, change the default case to log and continue rather than throw.
  3. Rename the binding in the parent to match the current parameter name after a refactor.
  4. Use the compiler/Live compiler diagnostics to catch attribute-name mismatches during build.

Example fix

// before
default:
    throw new ArgumentException($"Unknown parameter: {parameter.Name}");

// after — ignore unknown optional parameters with a warning
default:
    logger.LogWarning("Ignoring unknown parameter {Name}.", parameter.Name);
    break;
Defensive patterns

Strategy: validation

Validate before calling

// Caller: only pass declared parameters
<MyComponent Text="@text" TextChanged="@OnChange" CurrentTheme="@theme" MessageId="@id" />

Try / catch

try { await component.SetParametersAsync(view); }
catch (ArgumentException ex) when (ex.Message.Contains("Unknown parameter"))
{
    logger.LogWarning(ex, "Caller passed an unknown parameter.");
}

Prevention

When it happens

Trigger: A consumer passes a parameter the component does not declare (e.g. typo 'Mesage' vs 'Message', or a parameter removed in a refactor but still bound by callers); a parent component binds a new parameter before the child is updated; mix-up between two similar components' parameter sets.

Common situations: Refactoring a component and forgetting to update parent bindings; typos in Razor attribute names; copy-pasting markup from a sibling component with a different parameter set; version upgrade where a parameter was renamed.

Related errors


AI-assisted analysis of dotnet/AspNetCore.Docs@c67a80103a (2026-08-13). Data as JSON: /api/errors/f2d43abb18c4da58. Report an issue: GitHub.