我有一個Html幫助器方法,它在我的控制器上調用Delete方法。MVC:System.Web.HttpException:在控制器上找不到公共操作方法'Delete'
public static MvcHtmlString DeleteEmployeeOtherLeave(this HtmlHelper html, string linkText, Leave _leave)
{
return html.RouteLink(linkText, "Default",
new { _employeeOtherLeaveId = _leave.LeaveId, action = "Delete" },
new { onclick = "$.post(this.href); return false;" });
}
在我的控制器上,我有;
[AcceptVerbs(HttpVerbs.Delete)]
public ActionResult Delete(int _employeeOtherLeaveId)
{
EmployeeOtherLeaf.Delete(_employeeOtherLeaveId);
return RedirectToAction("Payroll");
}
但我得到這個運行時錯誤信息;
System.Web.HttpException: A public action method 'Delete' was not found on controller
兩個答案都是正確的。 – arame3333 2011-02-04 17:17:15