Reputation: 340
I want to route the following URL;
/anything/anything-v43243-anything
How can i route this to a specific controller and action with that id as parameter? The text "anything" has to be a text with at least a few characters. The id needs to start with the letter "v". I want this to create friendly URL's
Upvotes: 4
Views: 116
Reputation: 1039348
You could write a custom route for that and appropriate constraints for the different parts:
routes.MapRoute(
"myroute",
"anything/{x}-{id}-{y}",
new { controller = "SomeController", action = "SomeAction" },
new { x = "[a-z]+", y = "[a-z]+", id = @"\d+" }
);
Upvotes: 1