{"record":{"id":"d17c1af4f5e980d1","repo":"dotnet/aspnetcore","slug":"the-parameter-nameof-name-for-component-nam","errorCode":null,"errorMessage":"The parameter '{nameof(Name)}' for component '{nameof(CascadingValue<TValue>)}' does not allow null or empty values.","messagePattern":"The parameter '(.+?)' for component '(.+?)' does not allow null or empty values\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/CascadingValue.cs","lineNumber":81,"sourceCode":"        IsFixed = false;\n\n        foreach (var parameter in parameters)\n        {\n            if (parameter.Name.Equals(nameof(Value), StringComparison.OrdinalIgnoreCase))\n            {\n                Value = (TValue)parameter.Value;\n                hasSuppliedValue = true;\n            }\n            else if (parameter.Name.Equals(nameof(ChildContent), StringComparison.OrdinalIgnoreCase))\n            {\n                ChildContent = (RenderFragment)parameter.Value;\n            }\n            else if (parameter.Name.Equals(nameof(Name), StringComparison.OrdinalIgnoreCase))\n            {\n                Name = (string)parameter.Value;\n                if (string.IsNullOrEmpty(Name))\n                {\n                    throw new ArgumentException($\"The parameter '{nameof(Name)}' for component '{nameof(CascadingValue<TValue>)}' does not allow null or empty values.\");\n                }\n            }\n            else if (parameter.Name.Equals(nameof(IsFixed), StringComparison.OrdinalIgnoreCase))\n            {\n                IsFixed = (bool)parameter.Value;\n            }\n            else\n            {\n                throw new ArgumentException($\"The component '{nameof(CascadingValue<TValue>)}' does not accept a parameter with the name '{parameter.Name}'.\");\n            }\n        }\n\n        if (_hasSetParametersPreviously && IsFixed != previousFixed)\n        {\n            throw new InvalidOperationException($\"The value of {nameof(IsFixed)} cannot be changed dynamically.\");\n        }\n\n        _hasSetParametersPreviously = true;","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/CascadingValue.cs#L63-L99","documentation":"Thrown by CascadingValue<TValue>.SetParametersAsync when the Name parameter is explicitly set but resolves to null or an empty string. The Name parameter is optional, but if present it must be a non-empty string so that descendant components can match against it by name. Omitting Name entirely is valid; passing Name=\"\" is not.","triggerScenarios":"Writing <CascadingValue Name=\"\" ...> or binding Name to a variable that evaluates to null or empty at render time. The check is at CascadingValue.cs:76-82.","commonSituations":"Dynamically computing the Name from a variable that is sometimes empty; accidentally leaving Name=\"\" when copy-pasting markup; binding Name to a model field that hasn't been initialized.","solutions":["Remove the Name attribute entirely if you don't need name-based cascading (type-based matching works without it).","Ensure the Name value is always a non-empty string when set.","Guard the binding: only set Name when the value is non-empty."],"exampleFix":"// before\n<CascadingValue Name=\"@MaybeEmptyName\" Value=\"@_value\">\n    <Child />\n</CascadingValue>\n\n// after\n@if (!string.IsNullOrEmpty(MaybeEmptyName))\n{\n    <CascadingValue Name=\"@MaybeEmptyName\" Value=\"@_value\">\n        <Child />\n    </CascadingValue>\n}\nelse\n{\n    <CascadingValue Value=\"@_value\">\n        <Child />\n    </CascadingValue>\n}","handlingStrategy":"validation","validationCode":"if (Name is not null && string.IsNullOrEmpty(Name))\n    throw new ArgumentException(\"CascadingValue Name must be non-empty if set.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit the Name attribute entirely if you don't need name-based matching.","Guard dynamically-computed Name values with a non-empty check."],"tags":["blazor","cascading-value","configuration"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}