Other 4xx codes
All HTTP status codes in ASP.NET Core
4xx Client error
The request conflicts with the current state of the resource, for example a duplicate or an edit conflict.
In ASP.NET Core: Return it for unique-key violations or optimistic concurrency failures.
The StatusCodes constant, HttpStatusCode enum name, reason phrase, class, and how EnsureSuccessStatusCode() and the standard resilience handler treat 409.
| Constant | StatusCodes.Status409Conflict |
|---|---|
| HttpStatusCode | HttpStatusCode.Conflict |
| Reason phrase | Kestrel sends Conflict |
| Class | 4xx, client error |
| IsSuccessStatusCode | false |
| EnsureSuccessStatusCode() | throws HttpRequestException: Response status code does not indicate success: 409 (Conflict). |
| Standard resilience handler | does not retry it |
TypedResults.Conflict()
TypedResults.Conflict<TValue>(error)
Results.StatusCode(StatusCodes.Status409Conflict)
Results.Problem(statusCode: StatusCodes.Status409Conflict, detail: "...")Conflict()
Conflict(error)
StatusCode(StatusCodes.Status409Conflict)
Problem(statusCode: StatusCodes.Status409Conflict, detail: "...")Checked on Kestrel: Results.Conflict() returns 409.
What Results.Problem(statusCode: 409) sends (with AddProblemDetails()), as application/problem+json:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.10",
"title": "Conflict",
"status": 409,
"traceId": "0HNA1B2C3D4E5:00000001"
}A controller's Problem(statusCode: 409) sends the same body.
A bare StatusCode(409) in an [ApiController] also gets a ProblemDetails body automatically; Results.StatusCode(409) in a minimal API sends an empty body unless you add UseStatusCodePages().
Setup
builder.Services.AddProblemDetails();
app.UseStatusCodePages();
app.MapGet("/status/{code:int}", (int code) => Results.StatusCode(code));Request
GET /status/409 HTTP/1.1Response (recorded)
HTTP/1.1 409 Conflict
Content-Type: application/problem+json
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.10",
"title": "Conflict",
"status": 409,
"traceId": "0HNA1B2C3D4E5:00000001"
}Status code pages fill in a ProblemDetails body for any error status without one.
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