Request.GetNextPage link ignores maxPageSize Preference header
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
!-- markdownlint-disable MD002 MD041 -->
I am trying to implement pagination with nextpage link. So I want to read X number of records on each page until there are no more records.
Assemblies affected
Microsoft.AspNetCore.OData, Version=7.3.0.0
Reproduce steps
With odata.MaxPageSize= 10
In Startup
var builder = new RouteBuilder(app);
builder.Select().OrderBy().Filter().SkipToken();
private static readonly int pageSize = 20;
private static ODataQuerySettings querySettings = new ODataQuerySettings()
{
PageSize = pageSize,
EnsureStableOrdering = true,
};
public static PagedResponse<TOut> GetPageResult<TIn, TOut>(IQueryable<TOut> models, ODataQueryOptions<TIn> queryOptions, HttpRequest request)
{
var results = queryOptions.ApplyTo(models, querySettings) as IEnumerable<TOut>;
return new PagedResponse<TOut>(results, request.GetNextPageLink(pageSize),
request.HttpContext.ODataFeature().TotalCount);
}
Expected result
Results should have 10 elements and GetNextPageLink should use MaxPageSize preference header to generate a skiptoken.
Actual result
Results has 10 elements but GetNextPageLink ignores MaxPageSize and does not generate a skipToken
Additional detail
Maybe overload should be used, but how to create objectToSkipTokenValue
public static Uri GetNextPageLink(this HttpRequest request, int pageSize, object instance, Func<object, string> objectToSkipTokenValue);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied GetNextPageLink call and the ODataQuerySettings PageSize/MaxPageSize behavior, then run the reproduction using Microsoft.AspNetCore.OData 7.3.0. Compare the generated next-page URI with the expected request and verify that it honors the preference header and includes a skiptoken when required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100