public interface IExampleService { Task GetAllProductsAsync(ProductListRequest request); } public class ExampleService : IExampleService { private readonly string _baseInventoryUrl; public ExampleService(IOptions options) { _baseInventoryUrl = Url.Combine(options.Value.BaseUrl, "Products"); } public async Task GetAllProductsAsync(ProductListRequest request) { try { return await Url.Combine(_baseInventoryUrl,"GetProductList") .PostJsonAsync(request) .ReceiveJson(); } catch (FlurlHttpException ex) { Console.WriteLine(ex.Message); return null; } } } PRODUCTLIST.CSHTML @page @model ExampleRazor.Pages.ProductListModel @{ ViewData["Title"] = "Product List"; }

Product List : @Model.PageNumber of @Model.TotalPages

@if (!Model.ProductItems.Any()) {

No Products To Display

} else { @foreach (var product in Model.ProductItems) { }
Product Name Sku Product Type
@product.ProductName @product.SKU @product.TypeName
} PRODUCTLIST.CSHTML.CS using ExampleApi.Dtos.Product; using ExampleApi.Services.Contracts; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace ExampleRazor.Pages { public class ProductListModel : PageModel { private readonly IExampleService _exampleService; public ProductListModel(IExampleService exampleService) { _exampleService = exampleService; } public List ProductItems { get; set; } = []; [BindProperty(SupportsGet = true)] public string? ProductSearchTerm { get; set; } [BindProperty(SupportsGet = true)] public int PageNumber { get; set; } = 1; public int TotalPages { get; set; } = 0; public int PageSize { get; set; } = 10; public async Task OnGet() { var request = new ProductListRequest { PageNumber = PageNumber, PageSize = PageSize, ProductSearchTerm = ProductSearchTerm ?? "", }; var response = await _exampleService.GetAllProductsAsync(request); if (response != null) { TotalPages = (int)Math.Ceiling((double)response.TotalCount / PageSize); ProductItems = response.InventoryItems; } } } }