C# sending picture from httplistener

Viewed 80

I trying to send base64 picture from httplistener, but for some reason it doesn't render:

Issue

Code:

var gv = ImageToBase64(new Bitmap("bubble.png"), ImageFormat.Png);
revatry.SetHeaders(res, HttpResponseHeader.CacheControl, "cache", RevatryFramework.Mime.PNG);
// ImageToBase64 is stolen from Stack Overflow. It does properly convert as I send the output to the browser

// Extra code here because I tried some stuff to solve issue, but it didn't help; I removed it again, but I kept the variables
byte[] buffer = gv;
res.ContentLength64 = buffer.Length;
System.IO.Stream output = res.OutputStream; // ponse eul zrehgo
output.Write(buffer, 0, buffer.Length);

revatry.EndRequest(res);

I'm using this: https://github.com/blockplacer/Revatry for web, but whatever I tried I couldn't get the picture to work.

1 Answers
{
    var bobux = ImageToByte2(new Bitmap("bubble.png"));
    revatry.SetHeaders(res, HttpResponseHeader.CacheControl, "cache", RevatryFramework.Mime.PNG);
    res.ContentEncoding = Encoding.UTF8;

    // Console.WriteLine(bobux);
    byte[] buffer = bobux;

    res.ContentLength64 = buffer.Length; // ponse
    System.IO.Stream output = res.OutputStream; // ponse
    output.Write(buffer, 0, buffer.Length);
    // revatry.Send(, res);

    revatry.EndRequest(res);

I solved it by using that. I directly sent the binary data using byte.

Related