using System.Web; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace OliverBooth.Pages.Blog; /// /// Represents a class which defines the model for the /blog/page/# route. /// public class List : PageModel { /// /// Gets the requested page number. /// /// The requested page number. public int PageNumber { get; private set; } public string[] Tag { get; private set; } = []; /// /// Handles the incoming GET request to the page. /// /// The requested page number, starting from 1. /// The tag by which to filter results. /// public IActionResult OnGet([FromRoute(Name = "pageNumber")] int page = 1, [FromQuery(Name = "tag")] string? tag = null) { if (page < 2) { return RedirectToPage("Index"); } PageNumber = page; Tag = (tag?.Split('+').Select(HttpUtility.UrlDecode).ToArray() ?? [])!; return Page(); } }