Question: > 
> **Possible Duplicate:**  
> 
> [How to show a image in database in the image control of Asp.net?](https://stackoverflow.com/questions/2482104/how-to-show-a-image-in-database-in-the-image-control-of-asp-net) 
> 
> 
> 

I am returning a list of products from a database. Inside this list i am saving database images as bytearrays. Currently I am displaying about 30 products on a page and i would like to add their images next to the product information. What would be the easiest way to go about this?

What I have:

```
public Image PopulatePicture()
{
    Image newImage;
    //Read image data into a memory stream
    using (MemoryStream ms = new MemoryStream(ImageByteArray, 0, ImageByteArray.Length))
    {
        ms.Write(ImageByteArray, 0, ImageByteArray.Length);

        //Set image variable value using memory stream.
        newImage = Image.FromStream(ms, true);
    }
    return newImage;
}

```

I have an error on Image.FromStream (System.Web.UI.WebControls does not contain a definition for FromStream)

Answer: 
If your using Mvc its rather simple 

Simply write an action such as the following 

```
public FileContentResult Image()
{
   //Get the Byte Array for your image
   byte[] image = FilesBLL.GetImage();

   //Return a jpg
   //Note the second parameter is the files mime type
   return File(image, "image/jpeg");
}

```

See This Link For Mime types

<http://www.webmaster-toolkit.com/mime-types.shtml>

I highly suggest adding a column to your files table to store mime types (determine this on upload)

And in your view put down an image like this

```
<img src='@Url.Action("GalleryMediumThumb")'/>

```

for webforms see

[How to show a image in database in the image control of Asp.net?](https://stackoverflow.com/questions/2482104/how-to-show-a-image-in-database-in-the-image-control-of-asp-net)
A generic ASP.NET Handler (\*.ashx) could load the image from the database and stream it as a normal image to the browser. 

May this <http://coffeedrivendevelopment.net/2012/10/26/sharing-image-resources-between-wpf-and-asp-net/> will help you. It is about images in ressources, but the way is the same.