I have seen this post: MVC Handler for an unknown number of optional parameters but it's for MVC and doesn't seem to work for me as I get an error:
A path segment that contains more than one section, such as a literal section or a parameter, cannot contain a catch-all parameter.
I want to be able to have an indeterminate amount of params in a Url, I have the following route:
RouteCollection.MapPageRoute("ManyParam", "{*params}.html", "~/Default.aspx");
This also seems to trigger the error message above.
How can I set up a route to have an unknown number of parameters in web forms (not MVC).
I am trying to achieve the following urls:
www.example.com/some-thing.html
www.example.com/some-thing/else.html
www.example.com/and/some-thing/else.html
www.example.com/1/2/3/4/5/6.html
EDIT
It seems to work when I use the following:
RouteCollection.MapPageRoute("ManyParam", "{*params}", "~/Default.aspx");
The problem is with this is that it doesn't allow the .html
at the end.
"{*params}.html"
does not make it very clear what you want to achieve... – Alodee"{*path}"
for Url and have some sort of constraint that will require.html
at the end using 5 arguments override of MapPageRoute – AlodeeRouteCollection.MapPageRoute("ManyParam", "{*path}.html", "~/Default.aspx");
but I get the error:A path segment that contains more than one section, such as a literal section or a parameter, cannot contain a catch-all parameter.
Am I doing something wrong with the.html
at the end? – Tita