{"record":{"id":"c31f6bc675409fbf","repo":"PrismLibrary/Prism","slug":"navigationexception-unsupportedmauinavigation","errorCode":"NavigationException.UnsupportedMauiNavigation","errorMessage":"NavigationException.UnsupportedMauiNavigation","messagePattern":"NavigationException\\.UnsupportedMauiNavigation","errorType":"exception","errorClass":"NavigationException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/PageNavigationService.cs","lineNumber":1271,"sourceCode":"                {\n                    await currentPage.Navigation.PushModalAsync(page, animated ?? true);\n                }\n                else\n                {\n                    if (insertBeforeLast)\n                    {\n                        await InsertPageBefore(currentPage, page, navigationOffset);\n                    }\n                    else\n                    {\n                        await currentPage.Navigation.PushAsync(page, animated ?? true);\n                    }\n                }\n            }\n        }\n        catch (Exception ex)\n        {\n            throw new NavigationException(NavigationException.UnsupportedMauiNavigation, _pageAccessor.Page, ex);\n        }\n    }\n\n    protected virtual Task InsertPageBefore(Page currentPage, Page page, int pageOffset)\n    {\n        var firstPage = currentPage.Navigation.NavigationStack.Skip(pageOffset).FirstOrDefault();\n        currentPage.Navigation.InsertPageBefore(page, firstPage);\n        return Task.FromResult(true);\n    }\n\n    protected virtual Task<Page> DoPop(INavigation navigation, bool useModalNavigation, bool animated)\n    {\n        if (useModalNavigation)\n            return navigation.PopModalAsync(animated);\n        else\n            return navigation.PopAsync(animated);\n    }\n","sourceCodeStart":1253,"sourceCodeEnd":1289,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs#L1253-L1289","documentation":"PageNavigationService wraps the whole MAUI platform navigation operation in a try/catch and rethrows any non-Prism exception as a NavigationException with code UnsupportedMauiNavigation. It signals that an underlying MAUI navigation call (PushAsync, PopAsync, RemovePage, etc.) failed with a platform-level exception, preserving the original as InnerException.","triggerScenarios":"Any internal MAUI NavigationStack manipulation during GoBackAsync/GoBackToRootAsync/ProcessNavigation that throws - e.g. pushing a page while another navigation is in flight, popping an empty stack, or platform handler errors - inside the try block ending at line 1271.","commonSituations":"Rapid double-taps triggering concurrent navigations; popping pages from a stack that was cleared on Window creation; device/platform-specific handler failures (Android/iOS) during animated transitions; navigating before the main window/page is fully attached.","solutions":["Read the InnerException to identify the real MAUI failure; fix the underlying cause.","Serialize navigation calls (await each NavigateAsync/GoBackAsync; debounce buttons) to avoid concurrent navigations.","Check Navigation.NavigationStack contents before requesting pops or removals.","Ensure navigation happens after window activation (e.g. from OnNavigatedTo/lifecycle events, not before the window exists)."],"exampleFix":"// before\nNavigationService.NavigateAsync(\"Detail\");\nNavigationService.NavigateAsync(\"Other\"); // concurrent -> platform exception\n\n// after\nprivate Task _nav;\n_nav = _nav ?? _navigationService.NavigateAsync(\"Detail\"); // serialize\nawait _nav;","handlingStrategy":"try-catch","validationCode":"if (navigationInProgress) return;","typeGuard":null,"tryCatchPattern":"try\n{\n    await _navigationService.GoBackAsync();\n}\ncatch (NavigationException ex) when (ex.Code == NavigationException.UnsupportedMauiNavigation)\n{\n    // inspect ex.InnerException; log; debounce further navigations\n}","preventionTips":["Debounce buttons so only one navigation runs at a time.","Always await navigation calls before issuing another.","Log InnerException to diagnose the real platform failure."],"tags":["navigation","maui","platform-exception","wrapped-exception"],"backgroundTag":"unsupported-operation","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}