You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder if I could ask a question re: Microsoft.AspNetCore.Odata(8.0.8) and the next page url?
I'm a first timer writing a WebAPI and Odata, and I'm struggling with a task to change the url supplied for @odata.nextlink, to an external uri used by a third party accessing the Web API.
The problem I have is I have not found a way to establish whether setting NextLink is warranted for the incoming request? My Web API is using Edm Models for SQL Tables, and the Get requests are returning these models. I'm unable to get a count of what exact item counts are being returned in the JSON response (or I don't know how to is probably more the case).
If I use "this.Request.ODataFeature().NextLink" to check inside the ODataController's GET method if paging is set, the value is always null. I am having to set the next page link for the request in the controller, and relying on this returning null when it's not needed. This doesn't work for all requests received. The next page link is being added, and in some instances added continually without returning anything in each case (skip=200, skip=250, skip=300...).
The example code below omits the uri changes that would be part of the "if (this.Request.GetNextPageLink(pageSize: 50, this, null) != null)" statement and in here assigned to the this.Request.ODataFeature().NextLink.
If anyone can point me in the right direction that would be great thanks.
[Route("dynarc")]
[EnableQuery(AllowedQueryOptions = AllowedQueryOptions.All, PageSize = 50, MaxNodeCount = 1000)]
public class VwCasesController : ODataController
{
private readonly ArchiveContext _context;
public VwCasesController(ArchiveContext context)
{
_context = context;
}
[HttpGet("Vwcase")]
public IActionResult GetVwCases(ODataQueryOptions<VwCase> options)
{
Uri nextLinkSet = this.Request.ODataFeature().NextLink; // always null and added just as an example of checking in case this is wrong?
if (this.Request.GetNextPageLink(pageSize: 50, this, null) != null)
{
this.Request.ODataFeature().NextLink = this.Request.GetNextPageLink(pageSize: 50, this, null);
}
return Ok(_context.VwCases.AsQueryable());
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Good afternoon,
I wonder if I could ask a question re: Microsoft.AspNetCore.Odata(8.0.8) and the next page url?
I'm a first timer writing a WebAPI and Odata, and I'm struggling with a task to change the url supplied for @odata.nextlink, to an external uri used by a third party accessing the Web API.
The problem I have is I have not found a way to establish whether setting NextLink is warranted for the incoming request? My Web API is using Edm Models for SQL Tables, and the Get requests are returning these models. I'm unable to get a count of what exact item counts are being returned in the JSON response (or I don't know how to is probably more the case).
If I use "this.Request.ODataFeature().NextLink" to check inside the ODataController's GET method if paging is set, the value is always null. I am having to set the next page link for the request in the controller, and relying on this returning null when it's not needed. This doesn't work for all requests received. The next page link is being added, and in some instances added continually without returning anything in each case (skip=200, skip=250, skip=300...).
The example code below omits the uri changes that would be part of the "if (this.Request.GetNextPageLink(pageSize: 50, this, null) != null)" statement and in here assigned to the this.Request.ODataFeature().NextLink.
If anyone can point me in the right direction that would be great thanks.
Cheers,
Beta Was this translation helpful? Give feedback.
All reactions