I was creating a sample mvc application and created two action methods (Index) in the Home controller.
public class HomeController : Controller
{
//
// GET: /Home/
public string Index()
{
return Index1();
}
public string Index(string message)
{
return "hello";
}
}
And the index is set as the default action in running the application. On running the application I get the below error,
The current request for action 'Index' on controller type 'HomeController' is ambiguous between the following action methods: System.String Index(Int32) on type Mvc4example.Controllers.HomeController System.String Index(System.String) on type Mvc4example.Controllers.HomeController
What I expected is that with out query string it'll invoke the parameterless action method and if there is a query string message is passed then the action method with parameter will get invoked.
Can anyone explain why this behavior?