title: output image using web api HttpResponseMessage
body: <p>I'm trying the following code to output a image from a asp.net web api, but the response body length is always 0.</p>
  
  <pre><code>public HttpResponseMessage GetImage()
  {
      HttpResponseMessage response = new HttpResponseMessage();
      response.Content = new StreamContent(new FileStream(@"path to image"));
      response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
  
      return response;
  }
  </code></pre>
  
  <p>Any tips?</p>
  
  <p>WORKS:</p>
  
  <pre><code>    [HttpGet]
      public HttpResponseMessage Resize(string source, int width, int height)
      {
          HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
  
          // Photo.Resize is a static method to resize the image
          Image image = Photo.Resize(Image.FromFile(@"d:\path\" + source), width, height);
  
          MemoryStream memoryStream = new MemoryStream();
  
          image.Save(memoryStream, ImageFormat.Jpeg);
  
          httpResponseMessage.Content = new ByteArrayContent(memoryStream.ToArray());
  
          httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
          httpResponseMessage.StatusCode = HttpStatusCode.OK;
  
          return httpResponseMessage;
      }
  </code></pre>