T4MVC - conflicts of different controllers

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 group/show/..., it works fine. But when I call Profile/Show/..., the parameter is zero. But if I delete UserProfile_Default, then both work, but the profile URL contains a question mark for the parameter (and I want it to be clean, like .../profile/show/5678)
It's seams that somehow one route blocks the other.

+3
source share
1 answer

Try instead:

routes.MapRoute(
    "Group_Default",
    "Group/{action}/{groupId}",
    new { controller = "Group" }
);

routes.MapRoute(
    "UserProfile_Default",
    "Profile/{action}/{userId}",
    new { controller = "Profile" }
);

- , , , URL- - : http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

+3

All Articles