title: Convert a Database retrieved byte array to an image in Razor View MVC
body: <p><strong>image with</strong> </p>
  
  <pre><code>src="data:image;base64,YmxvYjpodHRwJTNBLy9sb2NhbGhvc3QlM0ExNDE0MS8wMzI1ZTA3Mi1iOTA5LTQ0YjItOTVlNS1iYzc4ZmJhZTZhMzI=" attribute value isn't displayed
  with database table that has just one record with id=1
  </code></pre>
  
  <p><strong>Razor</strong> </p>
  
  <pre><code>&lt;img id="BlobPic" src="data:image;base64,@System.Convert.ToBase64String(Model.Logoo)" style="max-width:90%;" /&gt;
  </code></pre>
  
  <p><strong>Action method</strong></p>
  
  <pre><code>public FileContentResult getImg(int id)
          {
              BladiaInfoViewModel Bladia_Logo = rep.getByID(Convert.ToDecimal(1));
              byte[] byteArray = Bladia_Logo.Logoo;
              return new FileContentResult(Bladia_Logo.Logoo, "image/jpeg");
          }
  </code></pre>
  
  <p><strong>Jquery</strong></p>
  
  <pre><code>  $(document).ready(function () {
          $.ajax({
              url: '@Url.Action("getImg")',
                  data: { 'id': "1" },
                  type: "POST",
                  cache: false,
                  success: function (data) {
                      //document.getElementById("BlobPic").src = "data:image/png;base64," + data.Logoo;
                      document.getElementById("Logo").setAttribute("src",'@Url.Action("getImg", "BaldiaInfo",
                      new { id = Model.Logoo})');
  
                  },
                  error: function () {
                      alert("try again");
                  }
              });
              //----
          });
  </code></pre>