What is the difference when returning files between
public Stream getFile(string filename){
Stream s = _getFileStream(filename);
Response.AddHeader( "Content-Disposition", "attachment;filename=" + filename+ ";" );
return s;
}
and
public void getFile(string filename){
byte[] b = _getFileBytes(filename);
Response.AddHeader( "Content-Disposition", "attachment;filename=" + filename+ ";" );
Response.BinaryWrite(b)
}
and the method provided in the question here.
The problem I'm encountering is that sometimes parts of the image a user has uploaded appear scrambled. What's also odd is I cannot reproduce the problem locally - only when the application is on the www.
My thinking is that perhaps since my resources are local I wouldn't see the problem when streaming data and that the way I am streaming content back to the client isn't correct. So which is the "correct" (or recommended) way of returning the file?
HttpContext.Current.Response
. I want to go the WCF route and avoid the ASP.net stuff. – spots May 08 '13 at 18:28