Display image from IMAGE object in MVC

asp.net-mvc

Solution

You can write a handler to stream images out and then reference the streamer in your image tag.

For instance, you have http://myapp/media.ashx?imageId=10 stream out the image. In your page you reference like so: `<img src="http://myapp/media.ashx?imageId=10"/>`.

This way you don't have to temporarily write to disk.

Problem

I have an object of type IMAGE which holds image. I wanted to display the image in MVC view along with other controls. The way i can think of is to temporary store image on disk and set src of img control. I am sure there would be better way of doing this.

Original source

Related problems