Other 2xx codes
All HTTP status codes in ASP.NET Core
2xx Success
The response contains only the byte range the client asked for with a Range header.
In ASP.NET Core: Static files and Results.File(..., enableRangeProcessing: true) handle it for you.
The StatusCodes constant, HttpStatusCode enum name, reason phrase, class, and how EnsureSuccessStatusCode() and the standard resilience handler treat 206.
| Constant | StatusCodes.Status206PartialContent |
|---|---|
| HttpStatusCode | HttpStatusCode.PartialContent |
| Reason phrase | Kestrel sends Partial Content |
| Class | 2xx, success |
| IsSuccessStatusCode | true |
| EnsureSuccessStatusCode() | does not throw |
| Standard resilience handler | does not retry it |
Results.StatusCode(StatusCodes.Status206PartialContent)
Results.Problem(statusCode: StatusCodes.Status206PartialContent, detail: "...")StatusCode(StatusCodes.Status206PartialContent)
Problem(statusCode: StatusCodes.Status206PartialContent, detail: "...")What Results.Problem(statusCode: 206) sends (with AddProblemDetails()), as application/problem+json:
{
"title": "Partial Content",
"status": 206,
"traceId": "0HNA1B2C3D4E5:00000001"
}A controller's Problem(statusCode: 206) sends a different body, because MVC only fills type and title for codes in ApiBehaviorOptions.ClientErrorMapping:
{
"status": 206,
"traceId": "0HNA1B2C3D4E5:00000001"
}Setup
app.UseStaticFiles();Request
GET /file.txt HTTP/1.1
Range: bytes=0-99Response (recorded)
HTTP/1.1 206 Partial Content
Content-Type: text/plain
Content-Range: bytes 0-99/1000
Etag: "1dcb4a0f6f8e2c0"
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxThe static file middleware supports ranges: 206 with Content-Range and only the requested bytes.
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