Routing to the actions with same names but different parameters
Posted
by zerkms
on Stack Overflow
See other posts from Stack Overflow
or by zerkms
Published on 2010-04-12T23:55:15Z
Indexed on
2010/04/13
0:13 UTC
Read the original article
Hit count: 732
asp.net-mvc
|routing
I have this set of routes:
routes.MapRoute(
"IssueType",
"issue/{type}",
new { controller = "Issue", action = "Index" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
Here is the controller class:
public class IssueController : Controller
{
public ActionResult Index()
{
// todo: redirect to concrete type
return View();
}
public ActionResult Index(string type)
{
return View();
}
}
why, when i request http://host/issue i get The current request for action 'Index' on controller type 'IssueController' is ambiguous between the following action methods:
I expect that first one method should act when there is no parameters, and second one when some parameter specified.
where did i made mistake?
UPD: possible duplicate: http://stackoverflow.com/questions/436866/can-you-overload-controller-methods-in-asp-net-mvc
© Stack Overflow or respective owner