{
  "id": "dotnet/aspnet-core-middleware-ordering",
  "signature": "System.InvalidOperationException: The 'UseRouting' method must be called before 'UseEndpoints' in the middleware pipeline.",
  "signature_zh": "System.InvalidOperationException: 必须在中间件管道中先调用 'UseRouting' 方法，然后才能调用 'UseEndpoints'。",
  "regex": "UseRouting.*must be called before.*UseEndpoints",
  "domain": "dotnet",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "ASP.NET Core middleware pipeline ordering violation: UseRouting must precede UseEndpoints, but they are reversed or missing.",
  "root_cause_type": "generic",
  "root_cause_zh": "ASP.NET Core 中间件管道排序违规：UseRouting 必须在 UseEndpoints 之前调用，但顺序颠倒或缺失。",
  "versions": [
    {
      "version": "ASP.NET Core 3.1.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ASP.NET Core 5.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ASP.NET Core 6.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ASP.NET Core 7.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ASP.NET Core 8.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Removing UseRouting entirely breaks endpoint routing for MVC or minimal APIs.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding duplicate UseRouting calls causes ambiguous routing state.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Moving UseEndpoints before UseRouting in the same method doesn't fix order in different Configure blocks.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure middleware order: app.UseRouting(); app.UseEndpoints(endpoints => { ... });",
      "success_rate": 0.95,
      "how": "Ensure middleware order: app.UseRouting(); app.UseEndpoints(endpoints => { ... });",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use app.UseRouting() and app.UseEndpoints() in the same Configure method, not split across partial classes.",
      "success_rate": 0.9,
      "how": "Use app.UseRouting() and app.UseEndpoints() in the same Configure method, not split across partial classes.",
      "condition": "",
      "sources": []
    },
    {
      "action": "For minimal APIs, ensure app.MapGet/Post are called after UseRouting and before UseEndpoints.",
      "success_rate": 0.85,
      "how": "For minimal APIs, ensure app.MapGet/Post are called after UseRouting and before UseEndpoints.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure middleware order: app.UseRouting(); app.UseEndpoints(endpoints => { ... });",
    "Use app.UseRouting() and app.UseEndpoints() in the same Configure method, not split across partial classes.",
    "For minimal APIs, ensure app.MapGet/Post are called after UseRouting and before UseEndpoints."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-8.0#order",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}