WDTBD: [FromUri]

I have an action method in my MVC Api controller. It is invoked as [httpget], so parameters are passed through in the querystring. In my case it’s an integer array:

Mydomain.com/[controllername]/[action]?id=1&id=2&id=3

But when I want to use parameter ‘id’ in my code, why is it null and not an array?

Obviously I need to add FromUri.

 [HttpGet]
 public HttpResponseMessage ChangeStateOfUsers([FromUri] int[] ids, bool state)

Didn’t read about it before.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s