title: Retrieve and display image from database using ASP.Net MVC
body: <p>I want to retrieve an image from database and then send it to view and display it as thumbnail. Here is my code but It has some error and I can't return the image properly.
  I'm using ASP.Net MVC and aspx pages.</p>
  
  <p>Controller :</p>
  
  <pre><code>public ActionResult showImg(int id)
  {
     var imageData = from m in db.Products
                     where m.ShopId == 3
                     select Image.FromStream(new MemoryStream(m.Product_img.ToArray()));
  
     return new FileStreamResult(new System.IO.MemoryStream(imageData), "image/jpeg");
  }
  </code></pre>
  
  <p>View :</p>
  
  <pre><code>&lt;img src='&lt;%= Url.Action("showImg", "image", new { id = ViewData["imageID"] } ) %&gt;' /&gt; 
  </code></pre>