Reputation: 42185
I'd like to add a constraint to a route parameter that I have. The route pattern is:
{region}/{controller}/{action}
where {region}
should only be UK
or US
.
How can I do this? Is there a regex I can apply here, or some other means of defining this?
Upvotes: 0
Views: 1788
Reputation: 13581
This question has been asked before. See:
In essence, use Regular Expressions:
routes.MapRoute(
"Search", // Route name
"Search/{affiliateId}", // URL with parameters
new { controller = "Syndication", action = "Search" }, // Parameter defaults
new { affiliateId = "SOME REGEX TO TEST GUID FORMAT" } // constraints
);
Upvotes: 2