c# - Difference between returning a Stream and writing to HTTP output stream -
what 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 method provided in question here.
the problem i'm encountering parts of image user has uploaded appear scrambled. what's odd cannot reproduce problem locally - when application on www.
my thinking perhaps since resources local wouldn't see problem when streaming data , way streaming content client isn't correct. "correct" (or recommended) way of returning file?
i resolved issue 2 changes.
- i took carlosfiguera said , changed
httpcontext.current.response.addheaders(...)
weboperationcontext.current.outgoingresponse.add(...)
- in webconfig located
binding
tag service had it'sbindingconfiguration
set , changedtransfermode
"streamed"
these 2 changes got images showing correctly.
Comments
Post a Comment