Class PartialContentHttpResult
A Minimal API IResult that returns HTTP 206 Partial Content with a Content-Range header.
Used to indicate that the response contains a subset of the requested resource.
public sealed class PartialContentHttpResult : IResult
- Inheritance
-
PartialContentHttpResult
- Implements
- Inherited Members
- Extension Methods
Remarks
This class implements the HTTP 206 Partial Content response as defined in RFC 9110 ยง15.3.7. It is the Minimal API equivalent of PartialContentResult (which targets MVC controllers).
The Content-Range header format is: {unit} {from}-{to}/{total}
This class is typically used by the ToHttpResult pagination overloads in
HttpResultExtensions and should rarely be instantiated directly in endpoint code.
Constructors
PartialContentHttpResult(long, long, long?, IResult)
Initializes a new instance of the PartialContentHttpResult class with explicit range values.
public PartialContentHttpResult(long rangeStart, long rangeEnd, long? totalLength, IResult inner)
Parameters
rangeStartlongThe starting index of the range (zero-indexed, inclusive).
rangeEndlongThe ending index of the range (zero-indexed, inclusive).
totalLengthlong?The total number of items available, or null if unknown.
innerIResultAn IResult that writes the response body (e.g.,
Results.Ok(value)).
Remarks
The range is inclusive on both ends: [rangeStart, rangeEnd].
The Content-Range header uses "items" as the unit by default.
If totalLength is null, the header is formatted as: items {from}-{to}/*
PartialContentHttpResult(ContentRangeHeaderValue, IResult)
Initializes a new instance of the PartialContentHttpResult class with a pre-configured ContentRangeHeaderValue.
public PartialContentHttpResult(ContentRangeHeaderValue contentRangeHeaderValue, IResult inner)
Parameters
contentRangeHeaderValueContentRangeHeaderValueThe Content-Range header value to use in the response.
innerIResultAn IResult that writes the response body (e.g.,
Results.Ok(value)).
Properties
ContentRangeHeaderValue
Gets the Content-Range header value that will be included in the response.
public ContentRangeHeaderValue ContentRangeHeaderValue { get; }
Property Value
Methods
ExecuteAsync(HttpContext)
Write an HTTP response reflecting the result.
public Task ExecuteAsync(HttpContext httpContext)
Parameters
httpContextHttpContextThe HttpContext for the current request.
Returns
- Task
A task that represents the asynchronous execute operation.