How Web API returns multiple types

Viewed 30630

I am just wondering whether it is possible to return multiple types in a single Web Api. For example, I want an api to return both lists of customers and orders (these two sets of data may or may not relate to each other?

3 Answers

Instead of this:

return ControllerContext.Request
       .CreateResponse(HttpStatusCode.OK, new { listInt, listString });

use this:

return Ok(new {new List<int>() { 1, 2 }, new List<string>() { "a", "b" }});
Related