PrismLibrary/Prism · error · NavigationException

No Page has been registered with the provided key

Error message

No Page has been registered with the provided key

What it means

AddNavigationPage looks up registrations of type NavigationPage in the view registry. If no NavigationPage has been registered (registry.ViewsOfType(typeof(NavigationPage)) is empty), it throws NavigationException(NoPageIsRegistered, nameof(NavigationPage)): 'No Page has been registered with the provided key'.

Solutions

  1. Register the NavigationPage in App: navigationBuilder.AddNavigationPage() inside CreateWindow, or ViewRegistration for typeof(NavigationPage) with a name like "NavigationPage".
  2. Navigate via Shell routes instead if the app is Shell-based and no NavigationPage is desired.
  3. Before calling, check registry.ViewsOfType(typeof(NavigationPage)).Any() and branch to a non-NavigationPage flow.

Example fix

// before
protected override IWindow CreateWindow(IActivationState activationState)
    => activationState.BuildWindow(null); // no NavigationPage registered
// after
protected override void RegisterTypes(IContainerRegistry containerRegistry) { ... }
protected override IWindow CreateWindow(IActivationState activationState)
{
    var navRegistry = ... ; // ensure: navigationBuilder.AddNavigationPage();
    return activationState.NavigationRegistry...
}
// simplest fix: register NavigationPage view so ViewsOfType(typeof(NavigationPage)) is non-empty
Defensive patterns

Strategy: validation

Validate before calling

var registrations = registry.ViewsOfType(typeof(NavigationPage));
if (!registrations.Any())
    throw new InvalidOperationException("Register a NavigationPage view (e.g. navigationBuilder.AddNavigationPage()) before using AddNavigationPage in navigation flows.");

Try / catch

try
{
    builder.AddNavigationPage();
}
catch (NavigationException ex) when (ex.Code == NavigationException.NoPageIsRegistered)
{
    logger.LogError(ex, "No NavigationPage registered in the view registry");
}

Prevention

When it happens

Trigger: Calling AddNavigationPage() in a navigation flow when the app never registered a NavigationPage view, e.g. missing navigationBuilder.AddNavigationPage() registration or ViewRegistration for typeof(NavigationPage) in App.RegisterTypes/CreateWindow.

Common situations: New Prism.Maui apps (Shell-based) that never registered a NavigationPage but use builder APIs assuming classic Xamarin-style navigation; removing NavigationPage registration during migration from Xamarin.Forms Prism.

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 PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/9b622030caf3d453. Report an issue: GitHub.

Appendix: source

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

    public static INavigationBuilder AddSegment<TViewModel>(this INavigationBuilder builder, Action<ISegmentBuilder> configureSegment) =>
        builder.AddSegment(GetNavigationKey<TViewModel>(builder), configureSegment);

    public static INavigationBuilder AddSegment<TViewModel>(this INavigationBuilder builder, bool useModalNavigation) =>
        builder.AddSegment<TViewModel>(b => b.UseModalNavigation(useModalNavigation));

    // Will check for the Navigation key of a registered NavigationPage
    public static INavigationBuilder AddNavigationPage(this INavigationBuilder builder) =>
        builder.AddNavigationPage(b => { });

    public static INavigationBuilder AddNavigationPage(this INavigationBuilder 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);
    }

    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();

View on GitHub (pinned to 358118cd64)