【发布时间】:2013-12-25 12:50:28
【问题描述】:
编译但不工作:
public class ProductController : Controller
{
public ActionResult List(int a)
{
return View();
}
public ActionResult List(int a, int b)
{
return View();
}
}
出现错误:
当前对控制器类型的操作“列表”请求 'ProductController' 在以下操作方法之间不明确: System.Web.Mvc.ActionResult List(Int32) 类型 Shop.Controllers.ProductController System.Web.Mvc.ActionResult Shop.Controllers.ProductController 类型上的 List(Int32, Int32)
我对无法实施的原因感兴趣。
【问题讨论】:
-
ASP.NET MVC 只是一个 Web 框架。它根本不是一种编程语言。我认为没有支持问题..
-
MVC 旨在路由到一个动作,无论您是否实际传递了正确数量的参数。任何缺少的参数都将变为空,而任何额外的参数都将被忽略。因此,它会将您的重载方法视为重复操作。
标签: c# asp.net-mvc