We currently do not have out of box support for binding collection of values coming from Uri. Following is the issue regarding that and also the action disambiguation problem:
http://aspnetwebstack.codeplex.com/workitem/322
Unfortunately, i cannot think of a work around related to the Action selection problem(without the '{action}') itself even though you solve the problem of modelbinding to collection using a custom parameter binding like below:
public string GetByIds(int[] ids)
{
return "multiple";
}
------------------------
config.ParameterBindingRules.Insert(0, typeof(int[]), (paramDesc) => new SampleParameterBinding(paramDesc));
-------------------------
public class SampleParameterBinding : HttpParameterBinding
{
public SampleParameterBinding(HttpParameterDescriptor desc)
: base(desc)
{
}
public override bool WillReadBody
{
get
{
return false;
}
}
public override Task ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)
{
HttpRequestMessage currentRequest = actionContext.Request;
NameValueCollection nvc = currentRequest.RequestUri.ParseQueryString();
//TODO: ERROR CHECKS
int[] ids = nvc["ids"].Split(',').Select(str => Int32.Parse(str)).ToArray();
// Set the binding result here
SetValue(actionContext, ids);
// now, we can return a completed task with no result
TaskCompletionSource<AsyncVoid> tcs = new TaskCompletionSource<AsyncVoid>();
tcs.SetResult(default(AsyncVoid));
return tcs.Task;
}
private struct AsyncVoid
{
}
}