Fix broken pagination on Jobs/Shifts/Talent (Page param never bound)
CI/CD / CI · dotnet build (push) Successful in 5m14s
CI/CD / Deploy · hamkadr (push) Successful in 3m18s

The bound property was named Page, but 'page' is a reserved Razor Pages route value, so ?page=N never bound and stayed 1 — every page showed the first 24 results (you could never reach applicants/jobs beyond page 1). Renamed to PageNumber bound from a non-reserved 'p' param, and updated the pager to emit ?p=N.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-30 22:17:53 +03:30
parent 7acf94695f
commit 9bdbaecc15
4 changed files with 15 additions and 8 deletions
@@ -24,7 +24,9 @@ public class IndexModel : PageModel
[BindProperty(SupportsGet = true)] public string? RoleSlug { get; set; }
[BindProperty(SupportsGet = true)] public string? CitySlug { get; set; }
[BindProperty(SupportsGet = true)] public int Page { get; set; } = 1;
// NB: must NOT be named "Page" — "page" is a reserved Razor Pages route value, so a bound
// property called Page never picks up ?page=N (it stayed 1, breaking pagination). Bind from "p".
[BindProperty(SupportsGet = true, Name = "p")] public int PageNumber { get; set; } = 1;
private const int PageSize = 24;
public int TotalCount { get; private set; }
public int TotalPages { get; private set; }
@@ -86,7 +88,7 @@ public class IndexModel : PageModel
TotalCount = await q.CountAsync();
TotalPages = Math.Max(1, (int)Math.Ceiling(TotalCount / (double)PageSize));
CurrentPage = Math.Clamp(Page, 1, TotalPages);
CurrentPage = Math.Clamp(PageNumber, 1, TotalPages);
var skip = (CurrentPage - 1) * PageSize;
if (NearMeActive)
@@ -8,10 +8,11 @@
Func<int, string> pageUrl = p =>
{
var parts = Context.Request.Query
.Where(kv => !string.Equals(kv.Key, "Page", StringComparison.OrdinalIgnoreCase))
.Where(kv => !string.Equals(kv.Key, "p", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(kv.Key, "Page", StringComparison.OrdinalIgnoreCase))
.Select(kv => Uri.EscapeDataString(kv.Key) + "=" + Uri.EscapeDataString(kv.Value.ToString()))
.ToList();
parts.Add("Page=" + p);
parts.Add("p=" + p);
return Context.Request.Path + "?" + string.Join("&", parts);
};
var from = Math.Max(1, cur - 2);
@@ -29,7 +29,9 @@ public class IndexModel : PageModel
[BindProperty(SupportsGet = true)] public string? RoleSlug { get; set; }
[BindProperty(SupportsGet = true)] public string? CitySlug { get; set; }
[BindProperty(SupportsGet = true)] public int Page { get; set; } = 1;
// NB: must NOT be named "Page" — "page" is a reserved Razor Pages route value, so a bound
// property called Page never picks up ?page=N (it stayed 1, breaking pagination). Bind from "p".
[BindProperty(SupportsGet = true, Name = "p")] public int PageNumber { get; set; } = 1;
private const int PageSize = 24;
public int TotalCount { get; private set; }
public int TotalPages { get; private set; }
@@ -99,7 +101,7 @@ public class IndexModel : PageModel
TotalCount = await q.CountAsync();
TotalPages = Math.Max(1, (int)Math.Ceiling(TotalCount / (double)PageSize));
CurrentPage = Math.Clamp(Page, 1, TotalPages);
CurrentPage = Math.Clamp(PageNumber, 1, TotalPages);
var skip = (CurrentPage - 1) * PageSize;
if (NearMeActive)
@@ -17,7 +17,9 @@ public class IndexModel : PageModel
[BindProperty(SupportsGet = true)] public int? RoleId { get; set; }
[BindProperty(SupportsGet = true)] public Gender? GenderFilter { get; set; }
[BindProperty(SupportsGet = true)] public string? Q { get; set; } // deep search
[BindProperty(SupportsGet = true)] public int Page { get; set; } = 1;
// NB: must NOT be named "Page" — "page" is a reserved Razor Pages route value, so a bound
// property called Page never picks up ?page=N (it stayed 1, breaking pagination). Bind from "p".
[BindProperty(SupportsGet = true, Name = "p")] public int PageNumber { get; set; } = 1;
private const int PageSize = 24;
public int TotalCount { get; private set; }
public int TotalPages { get; private set; }
@@ -67,7 +69,7 @@ public class IndexModel : PageModel
TotalCount = await q.CountAsync();
TotalPages = Math.Max(1, (int)Math.Ceiling(TotalCount / (double)PageSize));
CurrentPage = Math.Clamp(Page, 1, TotalPages);
CurrentPage = Math.Clamp(PageNumber, 1, TotalPages);
Results = await q.OrderByDescending(t => t.CreatedAt)
.Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToListAsync();