I would like to code two functions with same name and different parameters in controller as below.
[Route("Home/index")]
public JsonResult index()
{
return new JsonResult {Data = 'test1'};
}
[Route("Home/index/{id}")]
public JsonResult index(id)
{
return new JsonResult {Data = 'test2'};
}
But I got an the following error with this.
The current request for action 'index' on controller type 'HomeController' is ambiguous between the following action methods: System.Web.Mvc.JsonResult index() on type application.Controllers.HomeController System.Web.Mvc.JsonResult index(int) on type application.Controllers.HomeController