views:

22

answers:

1

I'm reading about URL routing at How to: Define Routes for Web Forms Applications and there's something in the example I don't understand. If you look at the example provided below,

routes.MapPageRoute("", "SalesReport/{locale}/{year}/{*queryvalues}", "~/sales.aspx");

specifically at

"SalesReport/{locale}/{year}/{*queryvalues}"

Why does queryvalues have an asterisk in front of it and locale and year don't?

A: 

The * indicates a "catch all" parameter, which essentially matches everything else in the requested URL.

Everything after the "year" parameter in the URL will get dumped into the queryvalues parameter. So for example, the URL

http://whatever/SalesReport/canada/1999/x=1

will give you a queryvalues variable populated with "x=1". But it will also match the URL

http://whatever/SalesReport/canada/1999/x=1/y=2/z=3

and queryvalues will be populated with "x=1/y=2/z=3".

You can only have one catch-all parameter in your route, and it has to be the final parameter.

womp
James Evans
I'm not inherently familiar with how webforms deals with routing tokens, but I imagine that's probably what happens, yes.
womp
I get it. Thanks for the explanation.
James Evans
No problem - good luck!
womp