OrchardCMS/OrchardCore · error · InvalidOperationException

Zone not found:

Error message

Zone not found: 

What it means

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.

Solutions

  1. Use the exact zone name defined by the active layout
  2. Pass required: false and null-check the result
  3. Add the zone to the layout with the ZoneTagHelper: <zone Name="Footer" />
  4. Confirm the expected theme/layout is actually active for the request

Example fix

// before
var footer = await RenderSectionAsync("Footer", required: true);
// after
var footer = await RenderSectionAsync("Footer", required: false);
if (footer != null) { /* render */ }
Defensive patterns

Strategy: validation

Validate before calling

if (!string.IsNullOrEmpty(zoneName) && !ThemeLayout.Zones[zoneName].IsNullOrEmpty()) { var html = await RenderSectionAsync(zoneName, required: false); }

Try / catch

try { var z = await RenderSectionAsync(name, required: true); } catch (InvalidOperationException e) when (e.Message.StartsWith("Zone not found")) { /* optional fallback content */ }

Prevention

When it happens

Trigger: 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"]).

Common situations: 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.

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


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/242ef9410f6d54a4. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.DisplayManagement/RazorPages/Page.cs:252

        ArgumentNullException.ThrowIfNull(name);

        return RenderSectionAsync(name, required: true);
    }

    /// <summary>
    /// Renders a zone from the RazorPages.
    /// </summary>
    /// <param name="name">The name of the zone to render.</param>
    /// <param name="required">Whether the zone is required or not.</param>
    public Task<IHtmlContent> RenderSectionAsync(string name, bool required)
    {
        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)