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.
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" }
);
精彩评论