{"record":{"id":"242ef9410f6d54a4","repo":"OrchardCMS/OrchardCore","slug":"zone-not-found-page","errorCode":null,"errorMessage":"Zone not found: ","messagePattern":"Zone not found: ","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.DisplayManagement/RazorPages/Page.cs","lineNumber":252,"sourceCode":"        ArgumentNullException.ThrowIfNull(name);\n\n        return RenderSectionAsync(name, required: true);\n    }\n\n    /// <summary>\n    /// Renders a zone from the RazorPages.\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 Task<IHtmlContent> RenderSectionAsync(string name, bool required)\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":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.DisplayManagement/RazorPages/Page.cs#L234-L270","documentation":"In the Razor Pages Page class, RenderSectionAsync resolves a named zone from ThemeLayout.Zones. When required is true and the zone is absent or empty, an InvalidOperationException ('Zone not found: <name>') is thrown. This surfaces layout/zone contract violations instead of silently rendering nothing.","triggerScenarios":"await RenderSectionAsync(\"Footer\", required: true) on a layout where the \"Footer\" zone was never created (no <zone Name=\"Footer\" /> and no other code populating ThemeLayout.Zones[\"Footer\"]).","commonSituations":"Zone name typos, layouts from a different theme lacking the requested zone, page code copied between themes, calling zone rendering when no themed layout is active.","solutions":["Use the exact zone name defined by the active layout","Pass required: false and null-check the result","Add the zone to the layout with the ZoneTagHelper: <zone Name=\"Footer\" />","Confirm the expected theme/layout is actually active for the request"],"exampleFix":"// before\nvar footer = await RenderSectionAsync(\"Footer\", required: true);\n// after\nvar footer = await RenderSectionAsync(\"Footer\", required: false);\nif (footer != null) { /* render */ }","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrEmpty(zoneName) && !ThemeLayout.Zones[zoneName].IsNullOrEmpty()) { var html = await RenderSectionAsync(zoneName, required: false); }","typeGuard":null,"tryCatchPattern":"try { var z = await RenderSectionAsync(name, required: true); } catch (InvalidOperationException e) when (e.Message.StartsWith(\"Zone not found\")) { /* optional fallback content */ }","preventionTips":["Mirror zone names between the Razor Pages layout and page code","Use required: false for optional zones","Define zones in the layout with <zone Name=\"...\" /> before referencing them"],"tags":["razor-pages","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"}