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.
Controller :
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");
}
View :
<img src='<%= Url.Action("showImg", "image", new { id = ViewData["imageID"] } ) %>' />