The easiest way might be to use a 'catch-all' route and parse it in the controller action. For example
config.Routes.MapHttpRoute(
name: "GetByCoordinatesRoute",
routeTemplate: "/GetByCoordinatesRoute/{*coords}",
defaults: new { controller = "MyController", action = "GetByCoordinatesRoute" }
public ActionResult GetByCoordinatesRoute(string coords)
{
int[][] coordArray = RegEx.Matches("\[(\d+),(\d+)\]")
.Cast<Match>()
.Select(m => new int[]
{
Convert.ToInt32(m.Groups[1].Value),
Convert.ToInt32(m.Groups[2].Value)
})
.ToArray();
}
Note: my parsing code is supplied just as an example. It's a lot more forgiving that what you asked for, and you probably need to add a more checks to it.
However, a more elegant solution would be to use a custom IModelBinder.
public class CoordinateModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
int[][] result;
// similar parsing code as above
return result;
}
}
public ActionResult GetByCoordinatesRoute([ModelBinder(typeof(CoordinateModelBinder))]int[][] coords)
{
...
}