# Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large. The max request body size is 30000000 bytes.

- **ID:** `dotnet/kestrel-request-body-too-large`
- **Domain:** dotnet
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| ASP.NET Core 6.0 | active | — | — |
| ASP.NET Core 7.0 | active | — | — |
| ASP.NET Core 8.0 | active | — | — |

## Workarounds

1. **Increase the limit for specific endpoints using the [RequestSizeLimit] attribute: [RequestSizeLimit(50_000_000)] public IActionResult Upload() { ... }** (90% success)
   ```
   Increase the limit for specific endpoints using the [RequestSizeLimit] attribute: [RequestSizeLimit(50_000_000)] public IActionResult Upload() { ... }
   ```
2. **Configure Kestrel globally in Program.cs: builder.WebHost.ConfigureKestrel(options => options.Limits.MaxRequestBodySize = 50 * 1024 * 1024); // 50 MB** (95% success)
   ```
   Configure Kestrel globally in Program.cs: builder.WebHost.ConfigureKestrel(options => options.Limits.MaxRequestBodySize = 50 * 1024 * 1024); // 50 MB
   ```

## Dead Ends

- **** — This disables the limit entirely, risking denial-of-service from large payloads. (80% fail)
- **** — Kestrel checks the uncompressed size; compression does not bypass the limit. (70% fail)
