Other 4xx codes
All HTTP status codes in ASP.NET Core
4xx Client error
The request body is larger than the server will accept. RFC 9110 renamed it from "Payload Too Large".
In ASP.NET Core: Kestrel sends it when a body exceeds MaxRequestBodySize (30,000,000 bytes by default).
The StatusCodes constant, HttpStatusCode enum name, reason phrase, class, and how EnsureSuccessStatusCode() and the standard resilience handler treat 413.
| Constant | StatusCodes.Status413RequestEntityTooLarge, StatusCodes.Status413PayloadTooLarge |
|---|---|
| HttpStatusCode | HttpStatusCode.RequestEntityTooLarge |
| Reason phrase | Kestrel sends Payload Too Large; HttpClient's ReasonPhrase is Request Entity Too Large; RFC name: Content Too Large |
| Class | 4xx, client error |
| IsSuccessStatusCode | false |
| EnsureSuccessStatusCode() | throws HttpRequestException: Response status code does not indicate success: 413 (Request Entity Too Large). |
| Standard resilience handler | does not retry it |
Results.StatusCode(StatusCodes.Status413RequestEntityTooLarge)
Results.Problem(statusCode: StatusCodes.Status413RequestEntityTooLarge, detail: "...")StatusCode(StatusCodes.Status413RequestEntityTooLarge)
Problem(statusCode: StatusCodes.Status413RequestEntityTooLarge, detail: "...")What Results.Problem(statusCode: 413) sends (with AddProblemDetails()), as application/problem+json:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.14",
"title": "Content Too Large",
"status": 413,
"traceId": "0HNA1B2C3D4E5:00000001"
}A controller's Problem(statusCode: 413) sends the same body.
A bare StatusCode(413) in an [ApiController] also gets a ProblemDetails body automatically; Results.StatusCode(413) in a minimal API sends an empty body unless you add UseStatusCodePages().
Setup
app.MapPost("/upload", async (HttpRequest req) =>
{
await req.Body.CopyToAsync(Stream.Null);
return "ok";
});Request
POST /upload HTTP/1.1
Content-Length: 30000001Response (recorded)
HTTP/1.1 413 Payload Too LargeKestrel's default limit is 30,000,000 bytes (about 28.6 MB). Exactly 30,000,000 bytes passed in our test; one more byte gets 413.
Fix: Raise it per endpoint with [RequestSizeLimit(100_000_000)] or .WithMetadata(new RequestSizeLimitAttribute(...)), or globally with KestrelServerOptions.Limits.MaxRequestBodySize. IIS and reverse proxies have their own limits.
Every response on this page was recorded from ASP.NET Core 10.0.12 on Kestrel in the Production environment; the HttpClient rows come from .NET 10.0.12 and Microsoft.Extensions.Http.Resilience 10.10.0.
All HTTP status codes in ASP.NET Core