title: Download file to client asynchronously
body: <p>I'm having a hard time getting something done.</p>
  
  <p>I am building an mailclient using asp.net MVC 4. </p>
  
  <p>I am at the point that i have to download an image related to a message ( NOT an attachment ) to the client browser.</p>
  
  <p>Now i have this setup : </p>
  
  <p>Client browser -> Controller/backend -> Mail server</p>
  
  <p>to clarify : i have a client request containing the content ID of the image, the right mailbox, message etc. With that information i can download the image from the Mail server and upload it to the client.
  Now comes the hard part: I want to do this asynchronous. I want to be able to download a chunk of 512 KB from the mailserver, decode that part, and send it to the client.. fetch - decode - send.. So long that the browser got all the data of the image. </p>
  
  <p>I just dont want to first download ALL the data first to the server and then create a new memorystream with all that data and return that as a fileresult. I am just too afraid of getting too large files in my memory and block other processes etc.</p>
  
  <p>I am planning to use this method too of uploading real attachments ( which could be 100's of MBs ). So i am gonna need that method later on.</p>
  
  <p>Now i just have no idea how to achieve this, because i have a connection to the mail server, and i have a connection to the client. and i have to pass data to a new stream or something to get this done..</p>
  
  <p>Can someone please help me?</p>
  
  <p>Edit: to clarify: no i cannot refer to the file on the mail server. i HAVE to download the file to the server through sockets.</p>
  
  <p>Edit2: could http chuncked be the solution? If yes, could you give me a small example? </p>