public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _db.Attach(Student).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw new Exception($"Student {Student.StudentID} not found!"); } return(RedirectToPage("/ListStudents")); }