title: c# Sending a file with HttpResponseMessage StreamContent, but no file is sent?
body: <p>I am trying to send a file on my pc to my client. I have looked around and most answers resembles this: <a href="https://stackoverflow.com/questions/26038856/how-to-return-a-file-filecontentresult-in-asp-net-webapi">How to return a file (FileContentResult) in ASP.NET WebAPI</a></p>
  <p>So I have tried implementing it myself, but I only manage to receive the headers. I must assume I am doing something wrong somewhere, but I can't tell where. I have a little trouble telling the c# versions apart, but the target it should work on is .Net 4.8.</p>
  <p>My code for sending the file:</p>
  <pre><code>[HttpGet(&quot;ftplog&quot;)]
  public HttpResponseMessage Get()
          {
              String fileName = &quot;FileZilla Server.log&quot;;
              String path = @&quot;C:\Users\jacqq\source\repos\testing\testing\Views\Home\FileZilla Server.log&quot;;
              FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
              
              var memoeryStream = new MemoryStream();
              fileStream.CopyTo(memoeryStream);
              memoeryStream.Seek(0, SeekOrigin.Begin);
  
              HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
  
              result.Content = new StreamContent(memoeryStream);
              result.Content.Headers.ContentType = new MediaTypeHeaderValue(&quot;application/octet-stream&quot;);
              result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue(&quot;attachment&quot;)
              {
                  FileName = fileName.ToString()
              };
  
              return result;
          } 
  </code></pre>
  <p>I have tried sending the FileStream instead of a MemoryStream and I have tried sending the file as ByteArrayContent, but I always only receive headers. I have checked, and the file is read correctly with data. It might be that my recieving code is wrong?</p>
  <pre><code>        public static async Task DownloadFileTaskAsync(HttpClient client, Uri uri, string FileName)
          {
              var s = await client.GetStreamAsync(uri);
  
              StreamReader reader = new StreamReader(s) ;
                  
              Console.WriteLine(&quot;Starting&quot;);
              Console.WriteLine(reader.ReadToEnd());
              Console.WriteLine(&quot;stopping&quot;);
          }
  </code></pre>
  <p>I am new to c#, so it might be I have overlooked something. If anyone know of a different/better way to send a file, I would be keen to hear that too.
  Here is what I recieve:</p>
  <pre><code>{&quot;version&quot;:{&quot;major&quot;:1,&quot;minor&quot;:1,&quot;build&quot;:-1,&quot;revision&quot;:-1,&quot;majorRevision&quot;:-1,&quot;minorRevision&quot;:-1},&quot;content&quot;:{&quot;headers&quot;:[{&quot;key&quot;:&quot;Content-Type&quot;,&quot;value&quot;:[&quot;application/octet-stream&quot;]},{&quot;key&quot;:&quot;Content-Disposition&quot;,&quot;value&quot;:[&quot;attachment; filename=\&quot;FileZilla Server.log\&quot;&quot;]}]},&quot;statusCode&quot;:100,&quot;reasonPhrase&quot;:&quot;Continue&quot;,&quot;headers&quot;:[],&quot;trailingHeaders&quot;:[],&quot;requestMessage&quot;:null,&quot;isSuccessStatusCode&quot;:false}
  
  </code></pre>
  <p>Please help, have been stuck for little too long.</p>