title: AspNet Core - Could not load the image from FileStreamResult
body: <p>Please help.</p>
  <p>I've been searching for hours now as I cannot display the image on the website. I'm using byte[] from database then return FileStreamResult in controller.</p>
  <p>Below is my code</p>
  <p><strong>.cshtml</strong></p>
  <pre><code> &lt;img src=&quot;@Url.Action(&quot;GetImage&quot;, &quot;User&quot;)&quot; /&gt;
  </code></pre>
  <p><strong>User Service</strong></p>
  <p>I was able to call the api with byte[] value.</p>
  <pre><code>    public async Task&lt;HttpResponseMessage&gt; GetImage()
      {
          var client = _clientFactory.CreateClient(&quot;ApiName&quot;);
          var response = await client.GetAsync(apiUrl);
          return response;
      }
  </code></pre>
  <p><strong>Controller</strong></p>
  <pre><code>    [ResponseCache(Duration = 10)]
      [HttpGet]
      public async Task&lt;IActionResult&gt; GetImage()
      {
          var response = await _user.GetImage();
          if (response.IsSuccessStatusCode)
          {
              var logo = await response.Content.ReadAsByteArrayAsync();
              var ms = new MemoryStream(logo);
              FileStreamResult result = new FileStreamResult(ms, &quot;image/png&quot;);
              result.FileDownloadName = &quot;logo1223.png&quot;;
              return result;
          }
  
          return null;
      }
  </code></pre>
  <p>API</p>
  <pre><code>        [HttpGet(&quot;logo&quot;)]
          public async Task&lt;IActionResult&gt; GetImage()
          {
              var someByte= await GetSomeImage();
              return Ok(someByte);
          }
  </code></pre>
  <p>when I tried to download or save the image file I get this result.</p>
  <p><a href="https://i.stack.imgur.com/TCs8P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TCs8P.png" alt="enter image description here" /></a></p>
  <p>Image is not loading from the website</p>
  <p><a href="https://i.stack.imgur.com/KTfRH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KTfRH.png" alt="enter image description here" /></a></p>
  <p><strong><strong>UPDATE</strong></strong>
  I tried to manually get the file then convert to byte[] and image is displaying properly on the website,
  I checked how they upload the image... I found out
  they are using below code to save image on DB.</p>
  <pre><code>var byteArr= Encoding.UTF8.GetBytes(Convert.ToBase64String(bArr.ToArray()))
  </code></pre>
  <p>Tried this modified controller</p>
  <pre><code> public async Task&lt;FileContentResult&gt; GetImage()
   {
              var img = Image.FromFile(@&quot;C:\Downloads\test.png&quot;);
              byte[] bArr = imgToByteArray(img);
              var a = Encoding.UTF8.GetBytes(Convert.ToBase64String(bArr.ToArray()));
              return File(bArr, &quot;image/png&quot;); // WORKING!!!
              //return File(a, &quot;image/png&quot;); // NOT WORKING!!
  }
  </code></pre>
  <p>Is there a way to convert it to original byte image?</p>