OrchardCMS/OrchardCore · error · InvalidOperationException
Zone not found:
Error message
Zone not found:
What it means
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.
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)
Example fix
// before
@await RenderSectionAsync("Headr", required: true)
// after
@await RenderSectionAsync("Header", required: false) Defensive patterns
Strategy: validation
Validate before calling
var zoneName = "Header";
bool exists = !(ThemeLayout.Zones[zoneName] is null) && !ThemeLayout.Zones[zoneName].IsNullOrEmpty();
if (exists) { await RenderSectionAsync(zoneName, required: false); } Try / catch
try { await RenderSectionAsync(name, required: true); } catch (InvalidOperationException e) when (e.Message.StartsWith("Zone not found")) { /* render default */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Zone not found:
- Fatal error, a Layout couldn't be created.
- The name attribute can't be empty
- The shape type ' ' is not found for the theme
- DisplayAsync requires an instance of IShape
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/49fa1805208e175c.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.DisplayManagement/Razor/RazorPage.cs:337
return RenderSectionAsync(name, required: true);
}
/// <summary>
/// Renders a zone from the layout.
/// </summary>
/// <param name="name">The name of the zone to render.</param>
/// <param name="required">Whether the zone is required or not.</param>
public new Task<IHtmlContent> RenderSectionAsync(string name, bool required)
{
// We can replace the base implementation as it can't be called on a view that is not an actual MVC Layout.
ArgumentNullException.ThrowIfNull(name);
var zone = ThemeLayout.Zones[name];
if (required && zone.IsNullOrEmpty())
{
throw new InvalidOperationException("Zone not found: " + name);
}
return DisplayAsync(zone);
}
public static object OrDefault(object text, object other)
{
if (text == null || Convert.ToString(text) == "")
{
return other;
}
return text;
}
/// <summary>
/// Returns the full escaped path of the current request.
/// </summary>View on GitHub (pinned to 4306c0717f)