dotnet/aspnetcore · error · ArgumentException
The parameter '{nameof(Name)}' for component '{nameof(Cascad
Error message
The parameter '{nameof(Name)}' for component '{nameof(CascadingValue<TValue>)}' does not allow null or empty values. What it means
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.
Source
Thrown at src/Components/Components/src/CascadingValue.cs:81
IsFixed = false;
foreach (var parameter in parameters)
{
if (parameter.Name.Equals(nameof(Value), StringComparison.OrdinalIgnoreCase))
{
Value = (TValue)parameter.Value;
hasSuppliedValue = true;
}
else if (parameter.Name.Equals(nameof(ChildContent), StringComparison.OrdinalIgnoreCase))
{
ChildContent = (RenderFragment)parameter.Value;
}
else if (parameter.Name.Equals(nameof(Name), StringComparison.OrdinalIgnoreCase))
{
Name = (string)parameter.Value;
if (string.IsNullOrEmpty(Name))
{
throw new ArgumentException($"The parameter '{nameof(Name)}' for component '{nameof(CascadingValue<TValue>)}' does not allow null or empty values.");
}
}
else if (parameter.Name.Equals(nameof(IsFixed), StringComparison.OrdinalIgnoreCase))
{
IsFixed = (bool)parameter.Value;
}
else
{
throw new ArgumentException($"The component '{nameof(CascadingValue<TValue>)}' does not accept a parameter with the name '{parameter.Name}'.");
}
}
if (_hasSetParametersPreviously && IsFixed != previousFixed)
{
throw new InvalidOperationException($"The value of {nameof(IsFixed)} cannot be changed dynamically.");
}
_hasSetParametersPreviously = true;View on GitHub (pinned to 294cab2f9b)
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.
Example fix
// before
<CascadingValue Name="@MaybeEmptyName" Value="@_value">
<Child />
</CascadingValue>
// after
@if (!string.IsNullOrEmpty(MaybeEmptyName))
{
<CascadingValue Name="@MaybeEmptyName" Value="@_value">
<Child />
</CascadingValue>
}
else
{
<CascadingValue Value="@_value">
<Child />
</CascadingValue>
} Defensive patterns
Strategy: validation
Validate before calling
if (Name is not null && string.IsNullOrEmpty(Name))
throw new ArgumentException("CascadingValue Name must be non-empty if set."); Prevention
- Omit the Name attribute entirely if you don't need name-based matching.
- Guard dynamically-computed Name values with a non-empty check.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot notify about changes because the {GetType()} is confi
- EqualTo validator requires a non-empty "other" parameter.
- FileExtensions validator requires a non-empty "extensions" p
- Range validator requires at least one of "min" or "max" para
- regex validator requires a non-empty "pattern" parameter.
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/d17c1af4f5e980d1.
Report an issue: GitHub.