,直到我安装了ASP.NET MVC的调用工作正常1.0 RTM。
错误:CS0121:的调用不明确以下方法或属性之间
<%Html.RenderAction(ProductItemList,产品); %>
公众的ActionResult ProductItemList()
{
返回视图(〜/查看/产品/ ProductItemList.ascx,_repository.GetProductList()了ToList());
}
解决方案
您有两种操作方法具有相同的签名, RenderAction
不能决定使用哪一个。你需要以某种方式使该行动是唯一的。
我经常看到这个的时候有一个 GET
和 POST
,没有和参数既是一个动作。一个简单的解决方法是增加的FormCollection形式
作为POST的参数。
[HTTPGET]
公众的ActionResult ProductItemList()
{
//得到
}
[HttpPost]
公众的ActionResult ProductItemList(的FormCollection形式)
{
// POST
}
The call was working fine until I installed 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());
}
解决方案
You have two action methods with the same signature, and the RenderAction
cannot decide which to use. You need to somehow make the actions unique.
I usually see this when there is a Action for a GET
and POST
, both without and parameters. An easy workaround is to add FormCollection form
as the parameter of POST.
[HttpGet]
public ActionResult ProductItemList()
{
//GET
}
[HttpPost]
public ActionResult ProductItemList(FormCollection form)
{
//POST
}