Table of Contents

Class PartialContentHttpResult

Namespace
Trellis.Asp
Assembly
Trellis.Asp.dll

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} Content-Range: items 0-24/100

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

rangeStart long

The starting index of the range (zero-indexed, inclusive).

rangeEnd long

The ending index of the range (zero-indexed, inclusive).

totalLength long?

The total number of items available, or null if unknown.

inner IResult

An 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

contentRangeHeaderValue ContentRangeHeaderValue

The Content-Range header value to use in the response.

inner IResult

An 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

ContentRangeHeaderValue

Methods

ExecuteAsync(HttpContext)

Write an HTTP response reflecting the result.

public Task ExecuteAsync(HttpContext httpContext)

Parameters

httpContext HttpContext

The HttpContext for the current request.

Returns

Task

A task that represents the asynchronous execute operation.