I’ve notice that StackOverflow use this url:
http://stackoverflow.com/posts/123123/revisions
How can I add such routing to ASP MVC (3 or 4)?
What if I wanted to add the number of the revision like so:
http://stackoverflow.com/posts/123123/revisions/2
which translate to
- Controller=posts
- PostID=123123
- SubController=revisions
- RevisionID=2
My problem is that I have to set the entier routing in advanced.
If I’ll be able to set routing of posts and add routing between a specific post resource to sub-resource called revisions I’ll be able too add /revision after any route that return post resource.
Thank you,
Ido.
Such a route is easy to define at the start:
But it is highly likely to match too much. This can be alleviated in two ways:
postIdandrevisionto positive integers (eg. regex\d+).Hard code the name of
controllerandaction:and thus allow this route to be placed early in the list of routes while only matching the very
specific URL format.