So I have two URLs that I need separate routes for:
/find-your-new-home/155-detroit/1234-some-value
and
/find-your-new-home/155-detroit/5555g-some-other-flipping-value
The route I have in place to handle #1 is:
routes.MapRoute(
"FindYourNewHomeCommunity",
"find-your-new-home/{market}/{community}.html",
new { controller = "Community", action = "Detail" }
);
I have an action filter on the "Detail" method that splits "155" from "detroit" and also splits "1234" from "some-flipping-value" and passes just the ID's to the action method (the id's are all that matter, the text values are inconsequential).
Now, the second route is almost exactly the same EXCEPT that there is a "g" after the "5555" value. This "g" indicates that it should call another action method ("CommunityGroup") on the Community Controller.
My question is: how do I configure two routes to handle these separately? I tried:
routes.MapRoute(
"FindYourNewHomeCommunityGroup",
"find-your-new-home/{market}/{communityId}g-{community}.html",
new { controller = "Community", action = "CommunityGroup" }
);
That doesn't work however, for two reasons:
1) Both URLs end up matching both routes as proven by Phil Haack's RouteDebugger.
2) Because of greedy matching (and this is why I used the text "flipping-value" in the sample URL), communityId ends up containing "5555-some-other-flippin" since it matches to the last occurrence of "g-" in the URL, which happens to be in the "flipping-value" text.
So my question is, how do I get a different action method to fire for these URLs?
EDIT: Just to clarify, these URLs are pre-defined by some other constraints I'm working in and cannot be changed. They have to follow exactly this format.