PrismLibrary/Prism · error · NavigationException

NavigationException.NoPageIsRegistered

NavigationException.NoPageIsRegistered

Error message

NavigationException.NoPageIsRegistered

What it means

AddNavigationPage looks up registrations for typeof(NavigationPage) in the view registry. If none exist it throws NavigationException with code NoPageIsRegistered, because a NavigationPage segment cannot be created for an unregistered page. Prism requires every navigable page to be registered by name in the IViewRegistry.

Solutions

  1. Register NavigationPage in the view registry: `registry.RegisterForNavigation<NavigationPage>(nameof(NavigationPage));` or `services.AddSingleton(new ViewRegistration { Name = nameof(NavigationPage), View = typeof(NavigationPage) });`
  2. Verify the registration happens before navigation at startup (CreateWindow / App setup).
  3. If you don't want a NavigationPage, remove the AddNavigationPage call and use AddSegment with your root page directly.

Example fix

// before
builder.AddSegment("MainPage").AddNavigationPage(); // throws if NavigationPage unregistered
// after (in app registration)
registry.RegisterForNavigation<NavigationPage>(nameof(NavigationPage));
builder.AddSegment("MainPage").AddNavigationPage();
Defensive patterns

Strategy: validation

Validate before calling

var regs = ((IRegistryAware)builder).Registry.ViewsOfType(typeof(NavigationPage));
if (!regs.Any()) throw new InvalidOperationException("Register NavigationPage before AddNavigationPage");

Type guard

null

Try / catch

try { builder.AddNavigationPage(); }
catch (NavigationException ex) when (ex.Code == NavigationException.NoPageIsRegistered)
{
    // register NavigationPage or continue without a navigation page segment
}

Prevention

When it happens

Trigger: Calling AddNavigationPage(...) on a tab/segment builder when the app's Prism registration contains no ViewRegistration for NavigationPage (no ViewsOfType<NavigationPage>() match).

Common situations: New Prism.Maui 9 apps that forgot `navigatorRegistry.Register<NavigationPage>()` / `RegisterViewType(nameof(NavigationPage), typeof(NavigationPage))`; migrating from Prism.Forms where NavigationPage was implicit; template projects where NavigationPage registration was removed.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/29f529b19f4bc0e6. Report an issue: GitHub.

Appendix: source

Thrown at src/Maui/Prism.Maui/Navigation/Builder/NavigationBuilderExtensions.cs:102

        var registrations = registryAware.Registry.ViewsOfType(typeof(NavigationPage));
        if (!registrations.Any())
            throw new NavigationException(NavigationException.NoPageIsRegistered, nameof(NavigationPage));

        var registration = registrations.Last();
        return builder.AddSegment(registration.Name, configureSegment);
    }

    public static ICreateTabBuilder AddNavigationPage(this ICreateTabBuilder builder) =>
        builder.AddNavigationPage(b => { });

    public static ICreateTabBuilder AddNavigationPage(this ICreateTabBuilder builder, Action<ISegmentBuilder> configureSegment)
    {
        if (builder is not IRegistryAware registryAware)
            throw new Exception("The builder does not implement IRegistryAware");

        var registrations = registryAware.Registry.ViewsOfType(typeof(NavigationPage));
        if (!registrations.Any())
            throw new NavigationException(NavigationException.NoPageIsRegistered, nameof(NavigationPage));

        var registration = registrations.Last();
        return builder.AddSegment(registration.Name, configureSegment);
    }

    /// <summary>
    /// Adds a NavigationPage to the Navigation Uri
    /// </summary>
    /// <param name="builder">The <see cref="INavigationBuilder"/>.</param>
    /// <param name="useModalNavigation">When <see langword="true" /> this will force Modal Navigation.</param>
    /// <returns>The <see cref="INavigationBuilder"/>.</returns>
    /// <remarks>This should only be used when you have a single <see cref="NavigationPage"/> registered for Navigation. Typically this is automatically registered for you by Prism.</remarks>
    public static INavigationBuilder AddNavigationPage(this INavigationBuilder builder, bool useModalNavigation) =>
        builder.AddNavigationPage(o => o.UseModalNavigation(useModalNavigation));

    /// <summary>
    /// Navigates back to the specified view model asynchronously.
    /// </summary>

View on GitHub (pinned to 358118cd64)