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();
datacontains what you're expecting? I've written similar code before and spent ages trying to work out why the downloaded file was wrong, when it was actually the data I was sending down that was duff! =)