2

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());
}
Community
  • 1
  • 1
Jack
  • 104
  • 1
  • 4

1 Answers1

2

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
  • 37,935
  • 10
  • 86
  • 125
  • 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(p => p.ProductItemList());%> – Jack Sep 10 '10 at 17:52
  • 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 Sep 10 '10 at 18:07
  • 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 Sep 11 '10 at 20:57
  • @Steve, completely understand. I put the attributes there for clarification on my explanation of separation of ambiguous methods. – Dustin Laine Sep 11 '10 at 22:17