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.

  1. i took carlosfiguera said , changed httpcontext.current.response.addheaders(...) weboperationcontext.current.outgoingresponse.add(...)
  2. in webconfig located binding tag service had it's bindingconfiguration set , changed transfermode "streamed"

these 2 changes got images showing correctly.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -