views:

53

answers:

1

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  A: 

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
}
Dustin Laine
I only have one method in the same controller. But I solved the problem. For MVC RTM, RenderAction cyntax is different than the previous. It is <%Html.RenderAction<namespace.controllers.controllerName>(p => p.ProductItemList());%>
Jack
RTM? Which version of MVC are you using. For 2.0 the syntax you had would have looked for an `ProductItemList` action in the `Product` controller. Glad its working for you.
Dustin Laine
RenderAction() is invoked from the View that is calling it. The [HttpGet] and [HttpPost] attributes are to be used for requests that are coming in from an actual Http request. RenderAction is inherently being called as a child request (not directly from Http).
Steve Michelotti
@Steve, completely understand. I put the attributes there for clarification on my explanation of separation of ambiguous methods.
Dustin Laine