The call is ambiguous between the following method or properties in ASP.NET MVC RenderAction

ぃ、小莉子 提交于 2019-12-11 02:35:07

问题


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

code snippet

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

Action Method

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

回答1:


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
}


来源:https://stackoverflow.com/questions/3686906/the-call-is-ambiguous-between-the-following-method-or-properties-in-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!