{"record":{"id":"f2d43abb18c4da58","repo":"dotnet/AspNetCore.Docs","slug":"unknown-parameter-parameter-name","errorCode":null,"errorMessage":"Unknown parameter: {parameter.Name}","messagePattern":"Unknown parameter: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"aspnetcore/blazor/performance/rendering.md","lineNumber":323,"sourceCode":"    {\n        foreach (var parameter in parameters)\n        {\n            switch (parameter.Name)\n            {\n                case nameof(MessageId):\n                    MessageId = (int)parameter.Value;\n                    break;\n                case nameof(Text):\n                    Text = (string)parameter.Value;\n                    break;\n                case nameof(TextChanged):\n                    TextChanged = (EventCallback<string>)parameter.Value;\n                    break;\n                case nameof(CurrentTheme):\n                    CurrentTheme = (Theme)parameter.Value;\n                    break;\n                default:\n                    throw new ArgumentException($\"Unknown parameter: {parameter.Name}\");\n            }\n        }\n\n        return base.SetParametersAsync(ParameterView.Empty);\n    }\n}\n```\n\nIn the preceding code, returning the base class <xref:Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync%2A> runs the normal lifecycle method without assigning parameters again.\n\n:::moniker range=\">= aspnetcore-8.0\"\n\nAs 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.\n\n:::moniker-end\n\n:::moniker range=\"< aspnetcore-8.0\"\n","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/dotnet/AspNetCore.Docs/blob/c67a80103a1a74db20784debd919c7fdda96c510/aspnetcore/blazor/performance/rendering.md#L305-L341","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Compare the bound attribute names against the component's declared parameters and remove or correct any mismatch.","If the parameter is intentionally optional/unknown, change the default case to log and continue rather than throw.","Rename the binding in the parent to match the current parameter name after a refactor.","Use the compiler/Live compiler diagnostics to catch attribute-name mismatches during build."],"exampleFix":"// before\ndefault:\n    throw new ArgumentException($\"Unknown parameter: {parameter.Name}\");\n\n// after — ignore unknown optional parameters with a warning\ndefault:\n    logger.LogWarning(\"Ignoring unknown parameter {Name}.\", parameter.Name);\n    break;","handlingStrategy":"validation","validationCode":"// Caller: only pass declared parameters\n<MyComponent Text=\"@text\" TextChanged=\"@OnChange\" CurrentTheme=\"@theme\" MessageId=\"@id\" />","typeGuard":null,"tryCatchPattern":"try { await component.SetParametersAsync(view); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Unknown parameter\"))\n{\n    logger.LogWarning(ex, \"Caller passed an unknown parameter.\");\n}","preventionTips":["Keep parent bindings in sync with the child's parameter names after refactors.","Use compiler diagnostics to catch attribute-name mismatches.","Consider logging unknown parameters instead of throwing for forward-compat.","Document the component's parameter surface explicitly."],"tags":["blazor","components","parameters","argumentexception","setparametersasync"],"backgroundTag":null,"analyzedSha":"c67a80103a1a74db20784debd919c7fdda96c510","analyzedAt":"2026-08-13T17:46:11.763Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}