title: Load images from database, problem displaying them
body: <p>In my view i have a image tag that looks like this: </p>
  
  <p><code>&lt;img src='@Url.Action( "Image", "Home", new { Id = @Id })'/&gt;</code></p>
  
  <p>This calls my method in my controller that looks like this:</p>
  
  <pre><code>    public string Image(int Id)
      {
          string strBase64 = "";
          using (SqlConnection con = OpenConnection())
          {
              SqlCommand cmd = new SqlCommand("spGetImageById", con);
              cmd.CommandType = CommandType.StoredProcedure;
  
              SqlParameter paramId = new SqlParameter()
              {
                  ParameterName = "@Id",
                  Value = Id
              };
              cmd.Parameters.Add(paramId);
  
              byte[] bytes = (byte[]) cmd.ExecuteScalar();
              strBase64 = "data:Image/png;base64," + Convert.ToBase64String(bytes);
          }
          return strBase64;
      }
  </code></pre>
  
  <p>This successfully returns my base64 image, but the image is not showing in the view. If i go to the www.url?Id=234 I see my base64 string,</p>
  
  <p><a href="https://i.stack.imgur.com/hjgh4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hjgh4.png" alt="enter image description here"></a></p>
  
  <p>So i tried to return that as a image instead like this:</p>
  
  <pre><code>return "&lt;img src=strBase64/&gt;;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5CF2B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5CF2B.png" alt="enter image description here"></a></p>
  
  <p>And that of course works. But how can i display the image directly when calling <code>&lt;img src='@Url.Action( "Image", "Home", new { Id = @Id })'/&gt;</code> from the view?
  The only thing I see is "error" image.</p>