I have the following two routes defined in my MVC app.;- At the moment I have two "MVC View content pages" defined
/ShowName/NameById
/ShowName/Index
However the content on these two pages are identical? Is it possible for two routes to share the same content page? If not then can I a) create a single rule for both routes or b) should I create a usercontrol to share between both content pages to show my data?
routes.MapRoute(
"NameById",
"Name/{theName}/{nameId}",
new
{
action = "NameById",
controller = "ShowName",
theName = "Charley"
}
,new { nameId = @"\d+" }
);
routes.MapRoute(
"ShowName",
"Name/{theName}",
new
{
action = "Index",
controller = "ShowName",
theName = "Charley"
}
);
EDIT I have read the answers below and I have the following action result methods. If I remove one of the methods (e.g. the Index) then how would I rewrite my routes to a single route?
public ActionResult Index(string theName)
public ActionResult NameById(string theName, int? nameId)
So the following works url's work?
/Name/Charley
/Name/Charley/11234