title: How to to return an image with Web API Get method
body: <p>I need to return an image with a Web API Get method. The code below seems to work fine except that I get this message in the Fiddler's ImageView window, "This response is encoded, but does not claim to be an image."   </p>
  
  <pre><code>public HttpResponseMessage Get()
  {
      using (FileStream fs = new FileStream(filePath, FileMode.Open))
      {
          HttpResponseMessage response = new HttpResponseMessage(); 
          response.Content = new StreamContent(fs);
          response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
          return response;
      }
  } 
  </code></pre>
  
  <p>I see the same result in the Fiddler with this code also:</p>
  
  <pre><code>public HttpResponseMessage Get()
  {
      HttpResponseMessage response = new HttpResponseMessage();
      Byte[] b = (GetImageByteArray());
      response.Content = new ByteArrayContent(b);
      response.Content.LoadIntoBufferAsync(b.Length).Wait();
      response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
      return response;
  }
  </code></pre>
  
  <p>I get the same result if I use .png format. </p>
  
  <p>Appreciate your help,</p>