的调用不明确的ASP.NET MVC RenderAction以下方法或属性之间 [英] The call is ambiguous between the following method or properties in ASP.NET MVC RenderAction
问题描述
,直到我安装了ASP.NET MVC的调用工作正常1.0 RTM。
错误:CS0121:的调用不明确以下方法或属性之间
code段
<%Html.RenderAction(ProductItemList,产品); %>
动作方法
公众的ActionResult ProductItemList()
{
返回视图(〜/查看/产品/ ProductItemList.ascx,_repository.GetProductList()了ToList());
}
您有两种操作方法具有相同的签名, RenderAction
不能决定使用哪一个。你需要以某种方式使该行动是唯一的。
我经常看到这个的时候有一个 GET
和 POST
,没有和参数既是一个动作。一个简单的解决方法是增加的FormCollection形式
作为POST的参数。
[HTTPGET]
公众的ActionResult ProductItemList()
{
//得到
}
[HttpPost]
公众的ActionResult ProductItemList(的FormCollection形式)
{
// POST
}
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());
}
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
}
这篇关于的调用不明确的ASP.NET MVC RenderAction以下方法或属性之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!