How to Get byte array properly from an Web Api Method in C#?

前端 未结 7 1194
故里飘歌
故里飘歌 2020-11-30 01:49

I have the following controller method:

[HttpPost]
[Route("SomeRoute")]
public byte[] MyMethod([FromBody] string ID)
{
  byte[] mybytearray = db.get         


        
7条回答
  •  甜味超标
    2020-11-30 02:24

    response.Content.ReadAsAsync().Result //Put this code in your client.

    I want to make it clear that ReadAsAsync() and ReadAsByteArrayAsync() do NOT act the same.

    ReadAsByteArrayAsync() turns everything into a Base64 Byte Array. It doesn't get the non-Base64 byte[] from response.Content but ReadAsAsync() does

提交回复
热议问题