{"record":{"id":"79ee9f3e3c510493","repo":"dotnet/aspnetcore","slug":"nameof-sectioncontent-requires-that-nameof-se","errorCode":null,"errorMessage":"{nameof(SectionContent)} requires that '{nameof(SectionName)}' and '{nameof(SectionId)}' cannot both have non-null values.","messagePattern":"(.+?) requires that '(.+?)' and '(.+?)' cannot both have non-null values\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Sections/SectionContent.cs","lineNumber":56,"sourceCode":"    [Parameter] public RenderFragment? ChildContent { get; set; }\n\n    void IComponent.Attach(RenderHandle renderHandle)\n    {\n        SectionRenderMode = renderHandle.RenderMode;\n        _registry = renderHandle.SectionRegistry;\n    }\n\n    Task IComponent.SetParametersAsync(ParameterView parameters)\n    {\n        // We are not using parameters.SetParameterProperties(this)\n        // because IsDefaultContent is internal property and not a parameter\n        SetParameterValues(parameters);\n\n        object? identifier;\n\n        if (SectionName is not null && SectionId is not null)\n        {\n            throw new InvalidOperationException($\"{nameof(SectionContent)} requires that '{nameof(SectionName)}' and '{nameof(SectionId)}' cannot both have non-null values.\");\n        }\n        else if (SectionName is not null)\n        {\n            identifier = SectionName;\n        }\n        else if (SectionId is not null)\n        {\n            identifier = SectionId;\n        }\n        else\n        {\n            throw new InvalidOperationException($\"{nameof(SectionContent)} requires a non-null value either for '{nameof(SectionName)}' or '{nameof(SectionId)}'.\");\n        }\n\n        if (!object.Equals(identifier, _registeredIdentifier) || IsDefaultContent != _registeredIsDefaultContent)\n        {\n            if (_registeredIdentifier is not null)\n            {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Sections/SectionContent.cs#L38-L74","documentation":"SectionContent identifies the section it supplies content for by either a string name (SectionName) or an object identifier (SectionId), but not both. The two are mutually exclusive identification modes; if both are non-null the component cannot decide which to register under, so SetParametersAsync throws InvalidOperationException. The check runs before the registry is touched, so no partial state is committed.","triggerScenarios":"Setting both SectionName=\"foo\" and SectionId=\"@someObject\" on the same <SectionContent> element. The properties are distinct [Parameter]s that are both populated from markup.","commonSituations":"Switching from name-based to id-based sections and leaving the old attribute in markup; copy-pasting from samples that use different identification styles; auto-completion adding both attributes.","solutions":["Pick one identifier style and remove the other attribute from <SectionContent>.","Use SectionName for static, declarative sections; use SectionId (a shared object instance) for sections resolved across components without magic strings.","If the design needs both, split into two SectionContent elements targeted at different outlets."],"exampleFix":"// before\n<SectionContent SectionName=\"banner\" SectionId=\"@myId\">...</SectionContent>\n// after — name only\n<SectionContent SectionName=\"banner\">...</SectionContent>","handlingStrategy":"validation","validationCode":"// In markup, set exactly one identifier. Programmatic check:\nif (sectionName is not null && sectionId is not null)\n    throw new InvalidOperationException(\"Set SectionName XOR SectionId, not both.\");","typeGuard":"static bool IsExclusiveSectionIdentifier(string? name, object? id)\n    => (name is not null) ^ (id is not null);","tryCatchPattern":null,"preventionTips":["Standardize on one identification style per project (name vs object id).","Use shared constants or a single shared object instance so the SectionContent and SectionOutlet pair is unambiguous.","Code-review SectionContent usages when migrating between identifier styles."],"tags":["blazor","sections","sectioncontent","configuration","invalidoperationexception"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}