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.

 

Blog op WordPress.com.

Omhoog ↑