views:

34

answers:

1

I am dealing with this code in a Web Forms scenario:

  public static void RegisterRoutes(RouteCollection routes)
  {

    Route r = new Route("{*url}", new MyRouteHandler());
    routes.Add(r);
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.IgnoreRoute("{resource}.gif/{*pathInfo}");

  }

Firstly, can anyone tell me where the defintion of {*pathInfo} is? http://msdn.microsoft.com/en-us/library/cc668201.aspx#url_patterns doesn't really define it. Does:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

Match

/c/xyz.axd and 
/b/c/xyz.axd and
/a/b/c/xyz.axd 

Whereas

routes.IgnoreRoute("{resource}.axd");

Only matches

/xyz.axd

Secondly, in:

{*url}

What does * mean? And what does the expression as a whole mean. Is there somewhere this is clearly explained?

Thirdly, is there a particular order I need to add these expressions to correctly ignore routes? I know {*url} is some kind of catchall, should the IgnoreRoutes come before or after it eg

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.gif/{*pathInfo}");
Route r = new Route("{*url}", new MyRouteHandler());
routes.Add(r);
+1  A: 

pathinfo is just a label for a bucket. So for instance *pathinfo says put everything after {resource}.axd/ into pathinfo.

The routes are executing in the order you place them in the routes table, so if your very first route is a catch all the rest will never execute.

bleevo
Is my example of pathInfo above correct? If not, can you redo it so it is correct. I am still confused.
Petras
Your examples look fine, maybe you could post a route thats not working, then I can comment on that.
bleevo