I have a test that uploads a bytearray (image - jpg) to our database (Sql Server FileStream) and then retrieves it through a HttpHandler. Next I compare the two.
Now, they are almost the same except for the first four bytes...
What's in those first four bytes?
First byteArray : 255, 216, 255, 224, from here on they are the same
Second byteArray: 63, 63, 63, 63 ...
When retrieved from the db by the handler, the string is converted to a bytearray like this
Update
StringWriter writer;
SimpleWorkerRequest worker;
writer = new StringWriter();
worker = new SimpleWorkerRequest(page, query, writer);
HttpRuntime.ProcessRequest(worker);
writer.Flush();
var encoding=new ASCIIEncoding();
var blob = encoding.GetBytes(writer.GetStringBuilder().ToString());
return blob;