I have a controller method which returns byte[].
[ActionName("testbytes")]
public byte[] GetTestBytes() {
var b = new byte[] {137, 80, 78, 71};
return b;
}
when i hit the api, i get following result.
<base64Binary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">iVBORw==</base64Binary>
Also when i hit this api from custom HttpClient, i get 10 bytes as a response. Following is the code of custom HttpClient.
public async Task<byte[]> GetTestBytes() {
var uri = "apiPath/testbytes";
using (var client = new HttpClient())
{
var httpResponse = await client.GetAsync(uri, HttpCompletionOption.ResponseContentRead);
if (httpResponse.IsSuccessStatusCode) {
var bytes = await httpResponse.Content.ReadAsByteArrayAsync();
}
return bytes;
}
return null;
}
I am expecting 4 bytes while i am receiving 10 bytes in response.