diff --git a/aspnetcore/security/authorization/secure-data/samples/final3/Pages/Contacts/Delete.cshtml.cs b/aspnetcore/security/authorization/secure-data/samples/final3/Pages/Contacts/Delete.cshtml.cs index 8ecb7fb51c..286a34ae65 100644 --- a/aspnetcore/security/authorization/secure-data/samples/final3/Pages/Contacts/Delete.cshtml.cs +++ b/aspnetcore/security/authorization/secure-data/samples/final3/Pages/Contacts/Delete.cshtml.cs @@ -47,8 +47,6 @@ namespace ContactManager.Pages.Contacts public async Task OnPostAsync(int id) { - Contact = await Context.Contact.FindAsync(id); - var contact = await Context .Contact.AsNoTracking() .FirstOrDefaultAsync(m => m.ContactId == id); @@ -66,7 +64,7 @@ namespace ContactManager.Pages.Contacts return new ChallengeResult(); } - Context.Contact.Remove(Contact); + Context.Contact.Remove(contact); await Context.SaveChangesAsync(); return RedirectToPage("./Index");