Asp.net mvc 无法删除Html数据表项

Asp.net mvc 无法删除Html数据表项,asp.net-mvc,asp.net-mvc-4,Asp.net Mvc,Asp.net Mvc 4,我有一个html控件数据表,在该数据表中有一个名为“删除”的链接。当我单击“删除”时,我需要删除该项 动作链接 @Html.ActionLink("Delete", "ProductCategory", new { id = item.CategoryId }) 在我的控件中,我将删除该项,但问题是无法返回到视图,因为没有用于删除产品的任何视图。因为该操作链接的数据表位于另一个视图中 public ActionResult DeleteProduct(int id) <-- Id c

我有一个html控件数据表,在该数据表中有一个名为“删除”的链接。当我单击“删除”时,我需要删除该项

动作链接

 @Html.ActionLink("Delete", "ProductCategory", new { id = item.CategoryId })
在我的控件中,我将删除该项,但问题是无法返回到视图,因为没有用于删除产品的任何视图。因为该操作链接的数据表位于另一个视图中

 public ActionResult DeleteProduct(int id) <-- Id correct here
    {
        return View(_pc.DeleteProduct(id));

    }
public ActionResult DeleteProduct(int-id)而不是

return View(_pc.DeleteProduct(id));
用这个

_pc.DeleteProduct(id);
return RedirectToAction("Index", "ProductCategory");

在ActionLink中,第二个参数是操作的名称

@Html.ActionLink("Delete", "DeleteProduct", new { id = item.CategoryId })
如果索引位于同一控制器中:

    public ActionResult DeleteProduct(int id)
    {
        _pc.DeleteProduct(id);
        return RedirectToAction("Index");
    }