【发布时间】:2014-07-16 01:22:16
【问题描述】:
我有以下控制器方法:
[HttpPost]
[Route("SomeRoute")]
public byte[] MyMethod([FromBody] string ID)
{
byte[] mybytearray = db.getmybytearray(ID);//working fine,returning proper result.
return mybytearray;
}
现在在调用方法中(这也是另一个WebApi方法!)我是这样写的:
private HttpClient client = new HttpClient ();
private HttpResponseMessage response = new HttpResponseMessage ();
byte[] mybytearray = null;
response = client.GetAsync(string.Format("api/ABC/MyMethod/{0}", ID)).Result;
if (response.IsSuccessStatusCode)
{
mybytearray = response.Content.ReadAsByteArrayAsync().Result;//Here is the problem
}
现在,问题是MyMethod发送的字节数组是528字节,但是在制作ReadAsByteArrayAsync之后,大小变得更大(706字节)并且值也被弄乱了。
【问题讨论】:
标签: c# asp.net-web-api