Reputation: 3142
I'm creating a CMS, and want all request sent to Default.aspx except for the administrator route. Here is what I have:
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Ignore("favicon.ico");
RouteTable.Routes.MapPageRoute("Administrator",
"Administrator",
"~/Admin/Default.aspx");
RouteTable.Routes.MapPageRoute("CMS",
"{PageURL}",
"~/Default.aspx");
}
This is working for a request such as:
mywebsite.com mywebsite.com/test mywebsite.com/anothertest
However, I get a resource cannot be found for:
mywebsite.com/another/test
How can I alter my routing so that it catches multiple levels?
Upvotes: 0
Views: 303
Reputation: 67135
You could try making your {PageURL}
into {*PageURL}
(or I even think {*}
will work, but am not sure) using route wildcards.
Or, you could do something like PageURL/{*TheRest}
Just remember that wildcards are very powerful and should be put at the end of your routes since routes are figured out in order.
Upvotes: 2