views:

92

answers:

1

I need to use a URL like this:

http://mydomain.com/Box/Categ1/Categ2/Categ3/.../CategN/id1,id2,id3,...,idN

Then I tried to create a new route this way...

routes.MapRoute(
    "Box",
    "Box/{data}",
    new { controller = "Box", action = "Index"},
    new { data = @"([a-zA-Z0-9-,]+/?)+" }
);

But it just doesn't work. If I use any char instead of "/" (slashes) it works fine. Is it possible to use the slashes? I really would like see the URL like this.

+6  A: 

If you want to set the data variable to everything that comes after Box, just use the catch-all parameter.

routes.MapRoute(
    "Box",
    "Box/{*data}",
    new { controller = "Box", action = "Index"}
);
womp
Really... Thanks man!
Wellington
No problem. By default, the asp.net mvc routing engine separates everything into tokens using the slash as a divider... so I'm not sure how it would work in regular expressions, but probably not well ;)
womp