2

在我安装 ASP.NET MVC 1.0 RTM 之前,该调用运行良好。

Error: CS0121: The call is ambiguous between the following methods or properties

代码片段

<%Html.RenderAction("ProductItemList", "Product"); %>

动作方法

public ActionResult ProductItemList()
{
  return View("~/Views/Product/ProductItemList.ascx", _repository.GetProductList().ToList());
}
4

1 回答 1

2

您有两个具有相同签名的操作方法,并且RenderAction无法决定使用哪个。您需要以某种方式使操作变得独特。

我通常会在没有 and 参数的情况下看到 a GETand的 Action。POST一个简单的解决方法是添加FormCollection form为 POST 的参数。

[HttpGet]
public ActionResult ProductItemList()
{
    //GET
}

[HttpPost]
public ActionResult ProductItemList(FormCollection form)
{
    //POST
}
于 2010-09-10T17:47:48.033 回答