{
  "id": "dotnet/kestrel-request-body-too-large",
  "signature": "Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large. The max request body size is 30000000 bytes.",
  "signature_zh": "Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException：请求正文过大。最大请求正文大小为 30000000 字节。",
  "regex": "Microsoft\\.AspNetCore\\.Server\\.Kestrel\\.Core\\.BadHttpRequestException: Request body too large\\. The max request body size is \\d+ bytes\\.$",
  "domain": "dotnet",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The incoming HTTP request body exceeds the Kestrel server's configured maximum request body size limit, which defaults to ~28.6 MB (30,000,000 bytes) or can be customized via MaxRequestBodySize.",
  "root_cause_type": "generic",
  "root_cause_zh": "传入的 HTTP 请求正文超过了 Kestrel 服务器配置的最大请求正文大小限制，默认约为 28.6 MB（30,000,000 字节），或可通过 MaxRequestBodySize 自定义。",
  "versions": [
    {
      "version": "ASP.NET Core 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ASP.NET Core 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ASP.NET Core 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This disables the limit entirely, risking denial-of-service from large payloads.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Kestrel checks the uncompressed size; compression does not bypass the limit.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the limit for specific endpoints using the [RequestSizeLimit] attribute: [RequestSizeLimit(50_000_000)] public IActionResult Upload() { ... }",
      "success_rate": 0.9,
      "how": "Increase the limit for specific endpoints using the [RequestSizeLimit] attribute: [RequestSizeLimit(50_000_000)] public IActionResult Upload() { ... }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Configure Kestrel globally in Program.cs: builder.WebHost.ConfigureKestrel(options => options.Limits.MaxRequestBodySize = 50 * 1024 * 1024); // 50 MB",
      "success_rate": 0.95,
      "how": "Configure Kestrel globally in Program.cs: builder.WebHost.ConfigureKestrel(options => options.Limits.MaxRequestBodySize = 50 * 1024 * 1024); // 50 MB",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 [RequestSizeLimit] 属性增加特定端点的限制：[RequestSizeLimit(50_000_000)] public IActionResult Upload() { ... }",
    "在 Program.cs 中全局配置 Kestrel：builder.WebHost.ConfigureKestrel(options => options.Limits.MaxRequestBodySize = 50 * 1024 * 1024); // 50 MB"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/options",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-02-14",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}