Reputation: 1770
Let's say I have an action like
public ActionResult TheAction(string path) { ... }
What I want to do is to have a request like www.myapp.com/controller/TheAction/path/to/content pass the "path/to/content" part of the route as the "path" parameter to the action.
My guess is that I'd have to fiddle with a custom route/request handler but before donning the complicator's gloves I wanted to see if you guys had any other suggestions.
Upvotes: 3
Views: 1382
Reputation: 42246
Just register /{controller}/{action}/{*path}
in your route registration.
That makes the last parameter a catch-all, so it will include the rest of the path, just like you want.
So it will look something like:
routes.MapRoute(
"HasCatchAllPath",
"{controller}/{action}/{*path}",
new { controller = "Home", action = "Index" }
);
Upvotes: 6