【发布时间】:2012-10-11 14:06:57
【问题描述】:
我有两种方法:
public ActionResult Index(int? id)
{
return Redirect("/View/" + this.GetMenuItems().First().Id);
}
public ActionResult Index(int id, uint? limit)
{
当我转到 /View/1 - 我得到那个错误
当前对控制器类型“ViewController”的操作“Index”的请求在以下操作方法之间不明确:
SVNViewer.Controllers.ViewController 类型上的 System.Web.Mvc.ActionResult Index(System.Nullable1[System.Int32]) on type SVNViewer.Controllers.ViewController
System.Web.Mvc.ActionResult Index(Int32, System.Nullable1[System.UInt32])
我需要这两种方法,但要消除歧义错误,我该怎么做?
【问题讨论】:
-
将其中一种方法重命名为其他方法:索引的第二种方法 -> MenuItem 也许?或者,在第二个中将限制参数设为必需(不可为空)。
-
@Tommy 如果你回答这个问题,我会投票的
-
@Mark - 我很感激,但是当我遇到这个问题时,我没有足够的时间来制定一个好的答案,但我想为 testCoder 投入 2 美分!
标签: c# asp.net .net asp.net-mvc