title: return image byte array in an action of mvc controller and display image in javascript
body: <p>In MVC, We are going to get image from server and display it in client, GetImage Action in controller is as follows:</p>
  
  <pre><code>public byte[] GetImage()
  {
      byte[] imgByteArray=File.ReadAllBytes("Img1.jpeg");
      return imgByteArray  ;          
  }
  </code></pre>
  
  <p>And javascript code in client side is as follows:</p>
  
  <pre><code>$.ajax(
  ...
    success: function (response) {
                  $('#imgResult')
                   .attr('src', 'data:image/jpeg;base64,' + response);
             },
      error: function (er) {
                          alert(er);
            }
  </code></pre>
  
  <p>The response is received successfully but image is not displayed and src value is set to:</p>
  
  <pre><code>src="data:image/jpeg;base64,System.Byte[]"
  </code></pre>
  
  <p>How can resolve this issue?</p>