ASP.NET MVC RenderAction 中的以下方法或属性之间的调用不明确

发布于 2024-09-18 19:33:51 字数 364 浏览 3 评论 0原文

在我安装 ASP.NET MVC 1.0 RTM 之前,该调用工作正常。

错误:CS0121:以下方法或属性之间的调用不明确

代码片段

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

操作方法

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉梦枕江山 2024-09-25 19:33:51

您有两个具有相同签名的操作方法,并且 RenderAction 无法决定使用哪一个。你需要以某种方式使行动变得独特。

当存在 GETPOST 的操作(不带参数)时,我通常会看到这种情况。一个简单的解决方法是添加 FormCollection form 作为 POST 的参数。

[HttpGet]
public ActionResult ProductItemList()
{
    //GET
}

[HttpPost]
public ActionResult ProductItemList(FormCollection form)
{
    //POST
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文