I studied the System.Web.Routing , playing with restrictions, etc., but I see no way to implement this.
I am working on an ASP.NET website (not WAP, not MVC) using WebPages / Razor.
I am trying to implement a form of "nested routing" where the route may contain child routes that only try if the parent match; each child tries to match the "remainder" of the URI. Search the "depth-first" route if you want.
routes.Add(new ParentRoute("{foo}/{*remainder}", new[] { new ParentRoute("{bar}/{*remainder}", new[] { new Route("{baz}"), new Route("{zip}"), }), new ParentRoute("{qux}/{*remainder}", new[] { new Route("{baz}"), new Route("{zip}"), }), ));
I have reduced the necessary constraints / handlers (among other parameters) for brevity.
In any case, each step descending through the tree will correspond to the tail of the {*remainder} URI. If the branch fails, it moves up and down to the next, essentially testing something like:
foo foo/bar foo/bar/baz foo/bar/zip foo/qux foo/qux/baz foo/qux/zip
Now, of course, I do not ask "please write the code", but rather a gesture in the right direction.
Where do I want to look for an API to start implementing such a function? I can find countless tutorials and information about writing routes, restrictions, etc., but not about extending the routing mechanism.
Adding
I will just add as orders
Note: I know that generating URLs from a routing tree such as this will be difficult; this is not what I intend to implement.
I just realized that iterative route generation could be enough; therefore, I think, I will publish this as a possible answer in the near future. No, it is not. Too many edge cases.