title: Returning Images from WebApi
body: <p>I am making a Web Api and I need to return multiple images to the client. I am currently using a Base64 string for each image but this results in each request taking far too long. Is there a better, more efficient way of returning images?</p>
  
  <p>This is the code I am using:</p>
  
  <p>Controller:</p>
  
  <pre><code>    public LearningUnits GetLearningUnits([FromODataUri]Guid key)
      {
          var record = db.LearningUnits.SingleOrDefault(inst =&gt; inst.LearningUnitId == key);
  
          record.ImageURLPath = ImageHandler.ImageToByteArrayFromFilePath(record.ImageURLPath);
  
          return record;
      }
  </code></pre>
  
  <p>ImageToByteArray Method:</p>
  
  <pre><code>    public static string ImageToByteArrayFromFilePath(string imagefilePath)
      {
          byte[] imageArray = File.ReadAllBytes(imagefilePath);
  
          string baseImage = Convert.ToBase64String(imageArray);
  
          return baseImage;
      }
  </code></pre>