{"record":{"id":"49fa1805208e175c","repo":"OrchardCMS/OrchardCore","slug":"zone-not-found","errorCode":null,"errorMessage":"Zone not found: ","messagePattern":"Zone not found: ","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.DisplayManagement/Razor/RazorPage.cs","lineNumber":337,"sourceCode":"        return RenderSectionAsync(name, required: true);\n    }\n\n    /// <summary>\n    /// Renders a zone from the layout.\n    /// </summary>\n    /// <param name=\"name\">The name of the zone to render.</param>\n    /// <param name=\"required\">Whether the zone is required or not.</param>\n    public new Task<IHtmlContent> RenderSectionAsync(string name, bool required)\n    {\n        // We can replace the base implementation as it can't be called on a view that is not an actual MVC Layout.\n\n        ArgumentNullException.ThrowIfNull(name);\n\n        var zone = ThemeLayout.Zones[name];\n\n        if (required && zone.IsNullOrEmpty())\n        {\n            throw new InvalidOperationException(\"Zone not found: \" + name);\n        }\n\n        return DisplayAsync(zone);\n    }\n\n    public static object OrDefault(object text, object other)\n    {\n        if (text == null || Convert.ToString(text) == \"\")\n        {\n            return other;\n        }\n\n        return text;\n    }\n\n    /// <summary>\n    /// Returns the full escaped path of the current request.\n    /// </summary>","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.DisplayManagement/Razor/RazorPage.cs#L319-L355","documentation":"RazorPage.RenderSectionAsync looks up a named zone in ThemeLayout.Zones of the current layout. If the zone name does not exist (or is empty) and the call was made with required: true, the method throws InvalidOperationException naming the missing zone. It prevents silently rendering nothing when a layout zone is expected to exist.","triggerScenarios":"Calling await RenderSectionAsync(\"Header\", required: true) (or RenderSection with required defaulting to true) when ThemeLayout.Zones[\"Header\"] is null or empty because the layout does not define that zone.","commonSituations":"Typo in zone name (case-sensitive dictionary lookup), switching to a custom theme/layout that lacks the zone, calling RenderSectionAsync outside a layout context where ThemeLayout was never populated.","solutions":["Correct the zone name to match one defined in the layout (check ThemeLayout.Zones keys)","Call with required: false and handle the null/empty result","Add the zone to the layout (e.g. via ZoneTagHelper <zone Name=\"Header\" />) so it exists at render time","Verify ThemeLayout is set (the view runs within a themed layout, not a bare view)"],"exampleFix":"// before\n@await RenderSectionAsync(\"Headr\", required: true)\n// after\n@await RenderSectionAsync(\"Header\", required: false)","handlingStrategy":"validation","validationCode":"var zoneName = \"Header\";\nbool exists = !(ThemeLayout.Zones[zoneName] is null) && !ThemeLayout.Zones[zoneName].IsNullOrEmpty();\nif (exists) { await RenderSectionAsync(zoneName, required: false); }","typeGuard":null,"tryCatchPattern":"try { await RenderSectionAsync(name, required: true); } catch (InvalidOperationException e) when (e.Message.StartsWith(\"Zone not found\")) { /* render default */ }","preventionTips":["Cross-check zone names against the active theme's layout zones","Prefer required: false when a zone is optional","Add missing zones to the layout with <zone Name=\"...\" />","Watch for case sensitivity in zone names"],"tags":["razor","zones","layout","theming"],"backgroundTag":"resource-not-found","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}