Skip to content

FAQ and Troubleshooting

RzR edited this page May 1, 2026 · 1 revision

FAQ and Troubleshooting

Why is my paging metadata missing in the minimal-API response body?

You probably returned Results.Ok(paged.Response) or relied on the upstream ResultToHttpResult.ToHttpResult<T> adapter, which only serializes result.Response and drops the envelope. Switch to:

return paged.ToPagedHttpResult(ctx);

See Minimal API Integration.

My controller returns IActionResult but the standard headers are missing.

Check that:

  1. AddPagedListResultWeb(...) is called from Program.cs. Without it PagedResultActionFilter is not registered.
  2. The action returns an ObjectResult or a JsonResult (which PagedOkResult does). If it returns a custom IActionResult whose Value is not exposed through a public Value property, the header writer cannot find the paged envelope.
  3. EmitTotalCountHeader is true (it is by default). The four X-* headers are toggled together by this flag.

For minimal-API endpoints, the MVC filter does not run; you must attach the endpoint filter via WithPagedResult() on the route group or endpoint.

[FromPagedQuery] is not invoked.

PagedRequestModelBinderProvider only kicks in when:

  • the parameter type is assignable from PagedRequest;
  • the binding source is BindingSource.Query (i.e. [FromPagedQuery] is present);
  • the parameter is a complex type (so simple int/string query bindings are not affected).

If any of those is missing, the default complex-object binder takes over and you get an empty PagedRequest. Verify the attribute is present and that AddPagedListResultWeb has been called.

I get EF1001 warnings when probing the DbContext.

QueryableExtensions.GetDbContext(IQueryable) uses reflection to extract the DbContext instance from an EF Core IQueryable. EF Core marks the underlying members as internal and surfaces an EF1001 analyzer warning when they are accessed. This is expected. The reflection is intentional, the access pattern is stable across the supported EF Core versions, and the call is only used to resolve DefaultPrimaryKeyDefinition for the predefined-records pipeline. You can suppress the warning at file scope:

#pragma warning disable EF1001

How do I return 204 instead of 200 with an empty Response?

For minimal APIs, pass null to ToPagedHttpResult and the helper will return Results.NoContent() automatically. For MVC, add the check explicitly:

if (paged is null) return NoContent();
return PagedOkResult(paged);

Why are filters silently ignored?

The most common reasons:

  1. You called GetPagedAsync instead of GetPagedWithMainFiltersAsync or GetPagedWithFiltersAsync. The simple variant ignores the Filters collection.
  2. The request type is PagedRequest, not PageRequestWithFilters. The base type does not carry a Filters collection, so the filter pipeline has nothing to read.
  3. The property names in the filters are not in the AllowedFilter set of the registered PageableMetadata; the binder removed them. Check the binding errors under filter[i] keys.

How do I customize the failure status code?

builder.Services.AddPagedListResultWeb(o =>
{
    o.StatusCodeMapper = (result, defaultCode) => StatusCodes.Status422UnprocessableEntity;
});

The mapper is called by the upstream IProblemDetailsResultFactory whenever a paged result is serialized as ProblemDetails.

How do I plug a custom JSON serializer?

Set PagedListResultWebOptions.JsonSerializerOptions. The minimal-API ToPagedHttpResult reads the value and passes it to Results.Ok(paged, options). For MVC, configure the framework JSON pipeline as usual (AddJsonOptions(...)) — paged endpoints inherit those settings because the body is just an ObjectResult.

Why is the Link header not emitted on POST?

By design. RFC 5988 navigation only makes sense for safe, idempotent verbs and for endpoints whose URL is itself the canonical representation of the request. The library emits Link only when the verb is GET and PageCount > 0. If you serve a paginated POST, build the Link header yourself or expose a parallel GET endpoint.

Why does Server-Timing not appear?

Two reasons: (1) EmitServerTimingHeader defaults to false; set it to true in the options. (2) The header is only emitted when ExecutionDetails.ExecutionTimeMs > 0. The EF Core extensions populate the value automatically; if you build a PagedResult<T> by hand and never call SetExecutionTimeMs, the value stays -1 and the header is skipped.

Compile error: ambiguous reference to IResult.

Microsoft.AspNetCore.Http.IResult (minimal API) collides with RzR.ResultMessage.Abstractions.IResult (returned by the paged helpers). Add a using alias at the top of the file:

using LibResult = RzR.ResultMessage.Abstractions.IResult;

C# using aliases do not apply to closed generic types — for IResult<T> use the fully-qualified name RzR.ResultMessage.Abstractions.IResult<T>.

How do I run paginated queries on an in-memory list?

Cast the list to IQueryable<T> and call the Common builders directly, then slice manually. The PagedListResult package depends on EF Core's ToListAsync, so it is not the right tool for in-memory data:

var query = items.AsQueryable();
var rowCount = query.Count();
var slice = query
    .OrderBy(x => x.Id)
    .Skip((page - 1) * pageSize)
    .Take(pageSize)
    .ToList();

If you need the same envelope shape, build a PagedResult<T> manually with the page math.

Clone this wiki locally