Microsoft.AspNetCore.Server.Kestrel: BadHttpRequestException: Request body too large (max 30,000,000 bytes)
The upload exceeded Kestrel's default 30 MB request body limit.
Exact message you may see
Request body too largeBadHttpRequestException Request body too largemaxAllowedContentLength 30000000
Seen on:
.NET ASP.NET Core
Meaning
MaxRequestBodySize defaults to about 28.6 MB. Form and multipart limits are separate (FormOptions.MultipartBodyLengthLimit is 128 MB). IIS has its own maxAllowedContentLength.
Common causes
- File larger than the Kestrel limit
- IIS request filtering limit
- Form options limit lower
- Reverse proxy limit
⚡ Quick fix
- Raise limits for the endpoint (
[RequestSizeLimit],DisableRequestSizeLimit) - Update
web.configfor IIS - Stream large uploads
Detailed fix by platform
C#
[RequestSizeLimit(200_000_000)]orbuilder.WebHost.ConfigureKestrel(o => o.Limits.MaxRequestBodySize = 200_000_000);
How to diagnose
- Layer — Kestrel, IIS or proxy?
- Limit — Which setting?
- Size — File size?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Most viewed in .NET
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- Unable to cast object of type System.InvalidCastException: Unable to cast object of type 'X' to type 'Y'
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Did this fix work for you?
Report a correction or suggest an improvement
Last updated 2 Dec 2026