public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Category = await _context.Categories.FindAsync(id); if (Category != null) { _context.Categories.Remove(Category); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }