Reputation: 3
I have, in Application_Start of global.asax
routes.MapPageRoute("Route2", "public/{folder2}/{folder1}/{page}", "~/userpage.aspx", true);
routes.MapPageRoute("Route1", "public/{folder1}/{page}", "~/userpage.aspx", true);
routes.MapPageRoute("Route0", "public/{page}", "~/userpage.aspx", true);
So each file (without extension) located in
is mapped to ~/userpage.aspx.
Can I use only one rule so as to include other paths such as
that will be mapped to ~/userpage.aspx?
Upvotes: 0
Views: 3434
Reputation: 3203
You can use a catch all parameter. A catch all parameter is defined by adding *
character at the beginning of the parameter name. It could be used only at the end of the route definition and it will catch the raw url string with slashes.
In your example it means that you will have to parse {page}
parameter manually from the RouteData
object.
routes.MapPageRoute("Route0", "public/{*fullpath}", "~/userpage.aspx", true);
Upvotes: 3