title: Display image from byte array in ASP.NET MVC Core
body: <p>I have a <code>byte[]</code> stored in a <code>VARBINARY(MAX)</code> column in a table in my database. 
  I want to show this image on my <code>index.cshtml</code> page - but I'm stuck.</p>
  
  <p>My CSHTML looks like this:</p>
  
  <pre><code>@using Microsoft.AspNetCore.Hosting.Internal
  @{
      ViewData["Title"] = "Title";
  }
  &lt;h2&gt;@ViewData["Title"]&lt;/h2&gt;
  &lt;h3&gt;@ViewData["Message"]&lt;/h3&gt;
  @if (!Context.User.Identity.IsAuthenticated)
  {
      &lt;p&gt;blah blah.&lt;/p&gt;
  
      &lt;p&gt;blah blah&lt;/p&gt;
  }
  
  @if (Context.User.Identity.IsAuthenticated)
  {
      &lt;p&gt;Hi @(Context.User.Identity.Name)&lt;br/&gt;&lt;/p&gt;
  
  
      &lt;p&gt;Where we off to today?&lt;/p&gt;
  }
  </code></pre>
  
  <p>I want to add </p>
  
  <pre><code>&lt;img src="...." /&gt; 
  </code></pre>
  
  <p>obviously I don't know what to do here.</p>
  
  <p>My model has the byte array data:</p>
  
  <pre><code> public byte[] UserImage { get; set; }
  </code></pre>
  
  <p>My controller assigned that the value:</p>
  
  <pre><code>  var model = new IndexViewModel
              {
                  Username = user.UserName,
                  Email = user.Email,
                  PhoneNumber = user.PhoneNumber,
                  IsEmailConfirmed = user.EmailConfirmed,
                  StatusMessage = StatusMessage,
                  UserImage = user.UserImage
              };
  </code></pre>
  
  <p>but I am using .net core in VS2017 and the answers I have found don't seem to work for me. Any help would be really appreciated.</p>
  
  <p>Thanks
  Johan</p>