I would like to handle all requests to not existing routes with MyRouteHandler If a request to an /existingfolder/existingpage.aspx happen I would like to serve it normal way by the server. (not only for pages, but scripts, images also). If a request coming to a not existing resource I would like to my MyRouteHandler to catch and serve it by instantiating an appropriate handler.
Currently I am using the following code, which is working, but ugly and not efficient I suppose:
private void RegisterMyRoutes(RouteCollection routes)
{
var myRouteHandler = new MyRouteHandler();
routes.Add(new Route("{f1}", MyRouteHandler));
routes.Add(new Route("{f1}/{f2}", MyRouteHandler));
routes.Add(new Route("{f1}/{f2}/{f3}", MyRouteHandler));
routes.Add(new Route("{f1}/{f2}/{f3}/{f4}", MyRouteHandler));
routes.Add(new Route("{f1}/{f2}/{f3}/{f4}/{f5}", MyRouteHandler));
}
Besides of the ugliness, of course this will not apply to a request with six level path, like /f1/f2/f3/f4/f5/f6.