How Web API returns multiple types
To return multiple types, you can wrap them into anonymous type, there are two possible approaches:
public HttpResponseMessage Get()
{
var listInt = new List<int>() { 1, 2 };
var listString = new List<string>() { "a", "b" };
return ControllerContext.Request
.CreateResponse(HttpStatusCode.OK, new { listInt, listString });
}
Or:
public object Get()
{
var listInt = new List<int>() { 1, 2 };
var listString = new List<string>() { "a", "b" };
return new { listInt, listString };
}
Also remember that The XML serializer does not support anonymous types. So, you have to ensure that request should have header:
Accept: application/json
in order to accept json format