dotnet/aspnetcore · error · ArgumentException
The parameter ' ' for component ' ' does not allow null or…
Error message
The parameter '{nameof(Name)}' for component '{nameof(CascadingValue<TValue>)}' does not allow null or empty values. What it means
Thrown by CascadingValue when the Name parameter is supplied with null or an empty string. A non-empty Name is required when supplying a named cascading value so that consumers can match it via a [CascadingParameter(Name = ...)]. The check runs during parameter setting, surfacing the misuse immediately.
Solutions
- Provide a non-empty, stable Name on the CascadingValue component (e.g. Name="theme").
- If the value is anonymous/unnamed, omit the Name attribute entirely (unnamed cascade).
- If Name is data-driven, guard the markup so <CascadingValue Name=...> only renders when the name is non-empty.
Example fix
<!-- before: empty name -->
<CascadingValue Name="" Value="dark">
<ThemedComponent />
</CascadingValue>
<!-- after: real name -->
<CascadingValue Name="theme" Value="dark">
<ThemedComponent />
</CascadingValue> Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(name)) { throw new ArgumentException("CascadingValue.Name must be non-empty.", nameof(name)); } Type guard
static bool IsValidCascadingName(string? name) => !string.IsNullOrEmpty(name);
Prevention
- Use a constant for the cascading value name to avoid typos and empties.
- Omit Name for anonymous cascades instead of passing an empty string.
- Guard data-driven Name values in the markup before rendering <CascadingValue>.
When it happens
Trigger: Authoring <CascadingValue Name=""> or passing a runtime value that resolves to null/empty for the Name parameter, while still attempting to provide a named cascade.
Common situations: Binding Name to a model property that is sometimes null; refactoring that leaves Name=""; copy-paste from a tutorial where the name was a placeholder.
Related errors
- ' ' is flagged with SingleDelivery, but the selected…
- Authorization requires a cascading parameter of type Task
- Do not specify both 'Authorized' and 'ChildContent'.
- The authorization data specifies an authentication scheme…
- The type ' ' does not have an associated TypeConverter that…
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/d17c1af4f5e980d1.
Report an issue: GitHub.
Appendix: 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 3600ca084e)