{"record":{"id":"bf5f1ed2a0357d2f","repo":"dotnet/aspnetcore","slug":"enhanced-navigation-does-not-support-making-a-non-bf5f1e","errorCode":null,"errorMessage":"Enhanced navigation does not support making a non-GET request to a non-Blazor endpoint. Avoid enabling enhanced navigation for forms that post to a non-Blazor endpoint.","messagePattern":"Enhanced navigation does not support making a non-GET request to a non-Blazor endpoint\\. Avoid enabling enhanced navigation for forms that post to a non-Blazor endpoint\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Services/NavigationEnhancement.ts","lineNumber":258,"sourceCode":"        } else {\n          throw new Error('Enhanced navigation does not support making a non-GET request to an endpoint that redirects to an external origin. Avoid enabling enhanced navigation for form posts that may perform external redirections.');\n        }\n      }\n\n      if (isSuccessResponse && response.headers.get('blazor-enhanced-nav') !== 'allow') {\n        // This appears to be a non-Blazor-Endpoint success response. We don't want to use enhanced nav\n        // because the content we receive is not designed to be patched into an existing frame,\n        // and may be incompatible with the Blazor JS that's already here.\n        // The reason we don't apply the same logic for non-success responses is that:\n        //  - We don't want to retry as then developers will get double-failures in logs\n        //  - We really want to show error pages to avoid losing vital debugging info\n        // ... and since error pages can be considered terminally fatal, we don't have to worry about\n        // whether the page has complex client-side behaviors that are incompatible with our JS.\n        if (isGetRequest) {\n          retryEnhancedNavAsFullPageLoad(internalDestinationHref);\n          return;\n        } else {\n          throw new Error('Enhanced navigation does not support making a non-GET request to a non-Blazor endpoint. Avoid enabling enhanced navigation for forms that post to a non-Blazor endpoint.');\n        }\n      }\n\n      // For 301/302/etc redirections to internal URLs, the browser will already have followed the chain of redirections\n      // to the end, and given us the final content. We do still need to update the current URL to match the final location,\n      // then let the rest of enhanced nav logic run to patch the new content into the DOM.\n      if (changeUrl && (response.redirected || treatAsRedirectionFromMethod)) {\n        const treatAsGet = treatAsRedirectionFromMethod ? (treatAsRedirectionFromMethod === 'get') : isGetRequest;\n        if (treatAsGet) {\n          // For gets, the intermediate (redirecting) URL is already in the address bar, so we have to use 'replace'\n          // so that 'back' would go to the page before the redirection\n          history.replaceState(null, '', response.url);\n        } else {\n          // For non-gets, we're still on the source page, so need to append a whole new history entry\n          if (response.url !== location.href) {\n            history.pushState(null, '', response.url);\n          }\n        }","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Services/NavigationEnhancement.ts#L240-L276","documentation":"Thrown by performEnhancedPageLoad (NavigationEnhancement.ts:258) when a non-GET (POST/PUT/etc.) enhanced form submission receives a success (2xx) response from an endpoint that is not a Blazor endpoint (identified by the missing 'blazor-enhanced-nav: allow' response header). Blazor refuses to patch arbitrary non-Blazor HTML into its DOM via a non-idempotent request because it cannot safely retry the POST as a full page load.","triggerScenarios":"An enhanced form (data-enhance) with method POST/etc. whose action targets a non-Blazor endpoint (static file, MVC without the Blazor middleware, external API proxied locally, or an endpoint that doesn't set the blazor-enhanced-nav header).","commonSituations":"Posting an enhanced Blazor form to a legacy MVC controller, a static HTML handler, a different ASP.NET Core app without the Blazor endpoint middleware, or an API endpoint; forgetting to add Blazor endpoints middleware to that route.","solutions":["Remove data-enhance from forms posting to non-Blazor endpoints.","Ensure the target endpoint goes through app.MapRazorComponents / the Blazor endpoints middleware so it emits blazor-enhanced-nav: allow.","Change the form method to 'get' if the endpoint supports it.","Post to a Blazor endpoint that participates in enhanced navigation."],"exampleFix":"<!-- before: enhanced form to legacy MVC -->\n<form method=\"post\" data-enhance action=\"/legacy/submit\">\n\n<!-- after -->\n<form method=\"post\" action=\"/legacy/submit\">\n<!-- or route the action through a Blazor component endpoint -->","handlingStrategy":"validation","validationCode":"function isBlazorEndpointCandidate(actionUrl: string): boolean {\n  // only heuristic; real check is the response header 'blazor-enhanced-nav: allow'\n  return actionUrl.startsWith(document.baseURI);\n}","typeGuard":"function isEnhancedNavAllowedResponse(res: Response): boolean {\n  return res.headers.get('blazor-enhanced-nav') === 'allow';\n}","tryCatchPattern":"try {\n  await performEnhancedPageLoad(url, false, fetchOptions);\n} catch (e) {\n  if (/non-Blazor endpoint/.test((e as Error).message)) {\n    // resubmit natively without enhanced nav\n  } else { throw e; }\n}","preventionTips":["Only mark forms as data-enhance when posting to Blazor endpoints.","Route target endpoints through app.MapRazorComponents / Blazor middleware.","Use 'get' forms for non-Blazor endpoints."],"tags":["blazor","enhanced-nav","forms","non-blazor-endpoint","navigation"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}