I’m trying to send binary data from a database over an ASP.NET page. I can see that the property data.Length is 2400, that means 2400 bytes, right?
The weird thing is that when i receive this data the size is ~4kb, and appears to be corrupted. Any idea what the problem might be?
byte[] data = proxy.getData(id);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=data.bin");
Response.AddHeader("Content-Length", data.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Write(data);
Response.Flush();
There are only 4 overloads of Response.Write:
And I would suspect that, based on your code (
Response.Write(data)), that you’re calling theobject objoverload. Have you tried:This is specifically intended for writing the contents of a byte array to the output stream.