diff --git a/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs b/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs index 69547c8..c654bda 100644 --- a/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs +++ b/src/JobsMedical.Web/Pages/Jobs/Index.cshtml.cs @@ -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) diff --git a/src/JobsMedical.Web/Pages/Shared/_Pager.cshtml b/src/JobsMedical.Web/Pages/Shared/_Pager.cshtml index 6eaf8b5..8632bd3 100644 --- a/src/JobsMedical.Web/Pages/Shared/_Pager.cshtml +++ b/src/JobsMedical.Web/Pages/Shared/_Pager.cshtml @@ -8,10 +8,11 @@ Func 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); diff --git a/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs b/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs index 3b5d1be..c467f05 100644 --- a/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs +++ b/src/JobsMedical.Web/Pages/Shifts/Index.cshtml.cs @@ -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) diff --git a/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs b/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs index d451d77..2007913 100644 --- a/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs +++ b/src/JobsMedical.Web/Pages/Talent/Index.cshtml.cs @@ -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();