views:

109

answers:

1

I have a problem with the wildcard route that I wonder if anyone can help on, I have a route as below

routes.MapRoute(
            "ReportRoute", 
            "Report/{*path}", 
            new { controller = "Home", action = "Index"})
            .RouteHandler = new ReportPathRouteHandler();

where the routehandler splits the path into its correct parts to get the correct report and this works great, if I put in a route www.mysite.com/report/folder1/folder2/report then I'll get what I'm looking for however my problem is if I have a link like www.mysite.com/report/folder1/report, the *path is only folder1/report and the routing really doesn't like this, in fact it doesn't even hit my route handler, just goes straight to 'resource can't be found' server error page. I tried to get around this by adding a new route before the wildcard as below

routes.MapRoute(
            "ReportRoute2",
            "Report/{path}/{name}",
            new { controller = "Home", action = "Index" });

where the Controller takes Path and Name as two string parameters but still no joy, has anyone got any ideas or pointers as to what can fix this issue? Thanks for your help.

A: 

The first example should be fine (except that odd .RouteHandler = new ReportPathRouteHandler(); at the end). What does your controller action look like? Does it take a "string path" as a parameter?

Cymen
The .routehandler is a class that takes the path and cuts into into it's parameters for the controller action, perhaps I should forgo that and just pass the full *path to the controller, using a routehandler seemed neater though
Israfel
Well what happens when you try it without the routehandler. It does sound useful (I'll go check it out) but I always try to keep it simple when problems come up and then slowly add back complexity.
Cymen
Been dragged into another project so will test it out and get back to you later
Israfel