I having some problems overloading the Index action in a controller. In the controller I have the following actions:
public ActionResult Index(int id)
{
return View();
}
public ActionResult Index()
{
return View();
}
Going to either URL (controllername/ or controllername/1) results in a 500 error. However when I use:
public ActionResult Index(int? id)
{
return View();
}
The controllername/ URL works but controllername/1 results in a 404 error. My global.asax is pretty vanilla:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
What I would like to do is be able to handle a null id as well as an integer id value. Any suggestions would be greatly appreciated.
Thanks!