Class HttpRequestPaginationExtensions
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
requestHttpRequestThe request whose query values are parsed.
cursorParameterstringThe query parameter containing the opaque cursor.
limitParameterstringThe query parameter containing the requested page size.
maxintThe maximum applied page size.
defaultSizeintThe page size used when
limitParameteris absent.policyPageSizeLimitPolicyHow a requested page size above
maxis 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
requestis null.- ArgumentException
A parameter name is null, empty, or whitespace, or the two names differ only by case.
- ArgumentOutOfRangeException
max,defaultSize, orpolicyis invalid.