Post handler for the Delete

Add an HTTP POST handler for the Delete buttons

A Razor page can include multiple forms. Since the Delete buttons in your list of pizzas modifies data, an HTTP POST rather that an HTTP GET is required.

Add the following OnPostDelete method to the PizzaModel class:

public IActionResult OnPostDelete(int id)
{
    PizzaService.Delete(id);
    return RedirectToAction("Get");
}

Last updated