3

Closed

Adding support for collection of simple types on the default action selector.

description

Currently if we have the following action, the request below would fail with "Multiple actions were found..." error because the parameters are not simple types so they're not used for disambiguation by the default action selector. For vnext, we can consider adding special support for collection of simple types.

public string Get([FromUri] IEnumerable<long> id)
public string Get([FromUri] IEnumerable<long> campaignId)

Request: GET /api/Test?id=1&id=2&id=3
Closed Mon at 12:05 AM by eilonlipton
Does not appear to be a very common scenario. We recommend using a workaround such as attribute routing, or using action-based dispatching instead of REST/verb dispatching. Another alternative is to not take any parameters and to read them manually from the query string.

One problem with this scenario is that it is ambiguous as to which method should be dispatched to. For example, what if there are id's and campaignId's? Or even if there are just id's, should the campaignId be called anyway but without any values?

comments

tugberk wrote Sep 29, 2012 at 8:35 AM

Before the action selector, this code is not even gonna compile. I am guessing that you probably meant something like this:

public string GetById([FromUri] IEnumerable<long> id)
public string GetByCampaignId([FromUri] IEnumerable<long> campaignId)