{"record":{"id":"6063335d2c1fe03e","repo":"dotnet/aspnetcore","slug":"nameof-sectionoutlet-requires-that-nameof-sec","errorCode":null,"errorMessage":"{nameof(SectionOutlet)} 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/SectionOutlet.cs","lineNumber":50,"sourceCode":"\n    internal IComponent? CurrentLogicalParent => _currentContentProvider;\n\n    void IComponent.Attach(RenderHandle renderHandle)\n    {\n        _renderHandle = renderHandle;\n        SectionRenderMode = renderHandle.RenderMode;\n        _registry = _renderHandle.SectionRegistry;\n    }\n\n    Task IComponent.SetParametersAsync(ParameterView parameters)\n    {\n        parameters.SetParameterProperties(this);\n\n        object? identifier;\n\n        if (SectionName is not null && SectionId is not null)\n        {\n            throw new InvalidOperationException($\"{nameof(SectionOutlet)} 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(SectionOutlet)} requires a non-null value either for '{nameof(SectionName)}' or '{nameof(SectionId)}'.\");\n        }\n\n        if (!object.Equals(identifier, _subscribedIdentifier))\n        {\n            if (_subscribedIdentifier is not null)\n            {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Sections/SectionOutlet.cs#L32-L68","documentation":"SectionOutlet — the consumer side of Blazor sections — identifies the section it renders by either SectionName (string) or SectionId (object), but never both. Setting both at parameter-set time is ambiguous: the outlet can only subscribe to one registry key, so SetParametersAsync throws InvalidOperationException before touching the registry. The check mirrors the one on SectionContent.","triggerScenarios":"Setting both SectionName=\"foo\" and SectionId=\"@someObject\" on the same <SectionOutlet> element.","commonSituations":"Switching identification styles and leaving both attributes in markup; copy-pasting between samples; auto-completion adding the second attribute.","solutions":["Choose one identifier style and remove the other attribute from <SectionOutlet>.","Keep the SectionOutlet identifier consistent with the corresponding SectionContent (both name-based or both id-based).","Use a shared constant or object instance to guarantee the pair matches."],"exampleFix":"// before\n<SectionOutlet SectionName=\"alerts\" SectionId=\"@alertsId\" />\n// after\n<SectionOutlet SectionName=\"alerts\" />","handlingStrategy":"validation","validationCode":"if (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.","Ensure the SectionOutlet identifier matches the corresponding SectionContent identifier.","Code-review when migrating between identifier styles."],"tags":["blazor","sections","sectionoutlet","configuration","invalidoperationexception"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}