public async Task <ActionResult> Delete(int id, IFormCollection collection) { try { // TODO: Add delete logic here if (id == null) { throw new Exception("Bad Delete Request"); } await _teacherRepo.Delete(id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { //View :<div asp-validation-summary="All" class="text-danger"> Debug.WriteLine("Delete error. " + ex.Message); ModelState.AddModelError(String.Empty, "Delete failed."); return(View()); } }