Jack
Jack

Reputation: 104

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

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());
}

Upvotes: 2

Views: 5503

Answers (1)

Dustin Laine
Dustin Laine

Reputation: 38543

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
}

Upvotes: 2

Related Questions