Table of Contents

Class HttpRequestPaginationExtensions

Namespace
Trellis.Asp
Assembly
Trellis.Asp.dll

Parses transport-neutral pagination values from ASP.NET Core requests.

public static class HttpRequestPaginationExtensions
Inheritance
HttpRequestPaginationExtensions
Inherited Members

Methods

TryCreatePageRequest(HttpRequest, string, string, int, int, PageSizeLimitPolicy)

Parses a cursor and limit from raw query values while preserving the distinction between a missing cursor and a present empty cursor.

public static Result<PageRequest> TryCreatePageRequest(this HttpRequest request, string cursorParameter = "cursor", string limitParameter = "limit", int max = 100, int defaultSize = 50, PageSizeLimitPolicy policy = PageSizeLimitPolicy.Clamp)

Parameters

request HttpRequest

The request whose query values are parsed.

cursorParameter string

The query parameter containing the opaque cursor.

limitParameter string

The query parameter containing the requested page size.

max int

The maximum applied page size.

defaultSize int

The page size used when limitParameter is absent.

policy PageSizeLimitPolicy

How a requested page size above max is handled.

Returns

Result<PageRequest>

A validated PageRequest, or an Error.InvalidInput whose field pointers identify the corresponding query parameters.

Remarks

Each query parameter may occur at most once. The limit is parsed using invariant integer rules, then both values are validated by TryCreate(string?, int?, int, int, PageSizeLimitPolicy, string?, string?). This extension is usable from Minimal API handlers and MVC actions, but does not add ApiExplorer or OpenAPI parameter metadata. Downstream cursor decoding remains transport-neutral; query-only endpoints should declare Query through endpoint input-origin metadata.

Exceptions

ArgumentNullException

request is null.

ArgumentException

A parameter name is null, empty, or whitespace, or the two names differ only by case.

ArgumentOutOfRangeException

max, defaultSize, or policy is invalid.