By default, overload methods are not supported in ASP.NET MVC. You must use delta actions or optional parameters. For instance:
public ActionResult Create() {} public ActionResult Create(string Skill, int ProductId) {} public ActionResult Create(Skill Skill, Component Comp) {}
will change to:
// [HttpGet] by default public ActionResult Create() {} [HttpPost] public ActionResult Create(Skill skill, Component comp, string strSkill, int? productId) { if(skill == null && comp == null && !string.IsNullOrWhiteSpace(strSkill) && productId.HasValue) // do something... else if(skill != null && comp != null && string.IsNullOrWhiteSpace(strSkill) && !productId.HasValue) // do something else else // do the default action }
OR
// [HttpGet] by default public ActionResult Create() {} [HttpPost] public ActionResult Create(string Skill, int ProductId) {} [HttpPost] public ActionResult CreateAnother(Skill Skill, Component Comp) {}
OR
public ActionResult Create() {} [ActionName("CreateById")] public ActionResult Create(string Skill, int ProductId) {} [ActionName("CreateByObj")] public ActionResult Create(Skill Skill, Component Comp) {}
See also this Q & A
source share