nizam nizam

nizam nizam

  • NA
  • 0
  • 12.4k

MVC4: The resource cannot be found

Feb 26 2015 4:42 AM

The resource cannot be found.

what is this error while i deleting a list  
//Get//
public ActionResult Delete(int id=0)
{
var head = db.Payroll_SalaryHeads.Find(id);
if (head == null)
{
return HttpNotFound();
}
return RedirectToAction("Index");
}

..POST// 
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id=0)
{
var head = db.Payroll_SalaryHeads.Find(id);
db.Payroll_SalaryHeads.Remove(head);
db.SaveChanges();
return RedirectToAction("Index");
}
 

Answers (1)

0
Manish Kumar Choudhary

Manish Kumar Choudhary

  • 165
  • 11k
  • 5.3m
Feb 26 2015 4:59 AM
change the name of the post action method.
 [HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult Delete_Post(int id=0)
{
var head = db.Payroll_SalaryHeads.Find(id);
db.Payroll_SalaryHeads.Remove(head);
db.SaveChanges();
return RedirectToAction("Index");
}