B
B
barsic12342020-01-27 16:08:00
.NET
barsic1234, 2020-01-27 16:08:00

How to correctly pass an array of bytes from a .NET Core application using the web api?

I'm trying to get an array of bytes from the api server using:
WebClient().DownloadData()
On the server, a .NET Core application, the method signature from which I'm trying to get an array: I tried to set the return type to byte[], but in both cases the web client receives some incomprehensible bytes. Maybe I'm just putting in the wrong type returned by the .net core application method?
public ByteArrayContent Get(string str)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-01-27
@barsic1234

Previously, there was no byte type in js, so an array of bytes was encoded in base64 string and sent to strings. Most likely the same is happening to you. Try to decode incoming bytes with Convert.FromBase64

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question