{"record":{"id":"bb8bdd315e927de0","repo":"PrismLibrary/Prism","slug":"the-generated-uri-has-one-or-more-relative-back-operators","errorCode":null,"errorMessage":"The generated URI has one or more relative back operators and was marked as an absolute path. This is not supported.","messagePattern":"The generated URI has one or more relative back operators and was marked as an absolute path\\. This is not supported\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Builder/NavigationBuilder.cs","lineNumber":109,"sourceCode":"    }\n\n    public INavigationBuilder WithParameters(INavigationParameters parameters)\n    {\n        foreach ((var key, var value) in parameters)\n            _navigationParameters.Add(key, value);\n\n        return this;\n    }\n\n    internal Uri BuildUri()\n    {\n        var uri = (_absoluteNavigation ? \"/\" : string.Empty) +\n            string.Join(\"/\", _uriSegments.Select(x => x.Segment));\n\n        if(uri.Contains(\"../\"))\n        {\n            if (_absoluteNavigation)\n                throw new InvalidOperationException(\"The generated URI has one or more relative back operators and was marked as an absolute path. This is not supported.\");\n\n            var segments = uri.Split('/');\n            if (!segments.Any(x => x != \"..\"))\n                throw new InvalidOperationException($\"The constructed URI contains one or more relative back operators, but contains no other navigation segments - '{uri}'.\");\n            var hasNonBackSegment = false;\n            for(int i = 0; i < segments.Length; i++)\n            {\n                if (hasNonBackSegment && segments[i] == \"..\")\n                    throw new InvalidOperationException($\"The constructed URI has a relative back operator after a new Navigation Segment which is not supported - '{uri}'.\");\n                else if (segments[i] != \"..\")\n                    hasNonBackSegment = true;\n            }\n        }\n\n        return UriParsingHelper.Parse(uri);\n    }\n}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Builder/NavigationBuilder.cs#L91-L127","documentation":"NavigationBuilder.BuildUri assembles the final navigation URI from accumulated segments. If '..' (RelativeBack) segments appear but _absoluteNavigation is true (builder created with absolute navigation), the resulting URI mixes an absolute root with relative back operators, which Shell/app navigation cannot resolve — so Prism throws InvalidOperationException.","triggerScenarios":"Using navigationService.CreateBuilder(absolute: true) (or UriPathIsAbsolute behavior) combined with .RelativeBack() segments: e.g. CreateBuilder absolute navigation then AddSegment(\"..\").","commonSituations":"Attempting to go back while also prefixing '/' for absolute paths; copying a relative-back navigation recipe into an absolute-navigation context; refactoring a relative navigation chain to absolute without removing back segments.","solutions":["Remove the RelativeBack()/'..' segments when using absolute navigation; use relative navigation if you need back operators.","Replace back-operator navigation with an explicit absolute path to the target page: AddSegment(\"HomePage\").AddSegment(\"DetailPage\").","If dynamic, check segments for '..' before setting _absoluteNavigation and downgrade to relative navigation."],"exampleFix":"// before\nvar builder = navigationService.CreateBuilder(useAbsoluteNavigation: true);\nbuilder.AddSegment(\"..\")... // not supported\n// after\nvar builder = navigationService.CreateBuilder(); // relative\nbuilder.RelativeBack().NavigateAsync();\n// or absolute without back:\nnavigationService.CreateBuilder(useAbsoluteNavigation: true).AddSegment(\"HomePage\").NavigateAsync();","handlingStrategy":"validation","validationCode":"if (isAbsoluteNavigation && segments.Any(s => s == \"..\"))\n    throw new InvalidOperationException(\"Back operators are not allowed with absolute navigation.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await navigationService.NavigateAsync(uri);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"relative back operators\"))\n{\n    logger.LogError(ex, \"Invalid navigation URI mixing absolute path and back operators\");\n}","preventionTips":["Never combine useAbsoluteNavigation:true with RelativeBack().","Encapsulate navigation building in a helper that enforces absolute-vs-relative rules.","For 'go up' semantics with absolute navigation, spell out the full target path instead."],"tags":["navigation","uri","absolute-path","unsupported-operation"],"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"}