Reputation: 6839
I have actions
public virtual ActionResult Show(string userId)
and
public virtual ActionResult Show(int groupId)
In Global.asax I have
routes.MapRoute(
"Group_Default",
"{controller}/{action}/{groupId}",
MVC.Groups.Show()
);
routes.MapRoute(
"UserProfile_Default",
"{controller}/{action}/{userId}",
MVC.Profile.Show()
);
Now when I request for group/show/...
it works fine. But when I call Profile/Show/...
parameter is null. But if I remove UserProfile_Default
then both works but profile URL contains question mark for parameter (and I want it clean like .../profile/show/5678
)
It seams that somehow one route block another.
Upvotes: 3
Views: 130
Reputation: 56449
Try these instead:
routes.MapRoute(
"Group_Default",
"Group/{action}/{groupId}",
new { controller = "Group" }
);
routes.MapRoute(
"UserProfile_Default",
"Profile/{action}/{userId}",
new { controller = "Profile" }
);
For future reference, the route debugger is a really good tool to see exactly what's going on with your routing and which URLs are hitting what actions: http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx
Upvotes: 3