public async Task <IActionResult> OnGetAsync(string categoryName, int pageNumber) { if (!string.IsNullOrEmpty(categoryName)) { ProductList = await _productApi.GetProductByCategory(categoryName); CategoryList = ProductList.Select(p => p.Category).Distinct(); SelectedCategory = categoryName; return(Page()); } else { ProductList = await _productApi.GetProducts(); CategoryList = ProductList.Select(p => p.Category).Distinct(); } if (pageNumber > 0) { ProductList = await _productApi.GetProductByPage(pageNumber); } return(Page()); }