I'm trying to write a MapRoute call that will make any route that is prefixed with "json/" prepend "json" to the action's name. For instance, a route something like this:
"json/{controller}/{action}"
with "json/Foo/Bar", it should result in:
controller = "Foo"
action = "jsonBar"
Any ideas?
I wonder if it wouldn't be better to include json in the route-data and look it up in the action? i.e. when mapping your route, use something like (for the defaults):
new { mode="json", controller = "Home", action = "Index", id = "" }
or map the route as:
"{mode}/{controller}/{action}"
then access this in the controller:
string mode = (string) RouteData.Values["mode"];
(or pass it in as an argument)
Other than that, you could potentially write your own route-handler, but that is a lot of work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With