I am trying to display the images in my Asp.Net MVC 1.0 application.
I can successfully get the Image (into byte[]
) from DB.
How can I display it into the <img>
?
I am trying to display the images in my Asp.Net MVC 1.0 application.
I can successfully get the Image (into byte[]
) from DB.
How can I display it into the <img>
?
Return a FileResult
from action method:
return File(imageData, "image/png");
Note that outputting HTML of the page and the image should be done in two separate requests. You have to generate a URL for the src
attribute to the action that returns the image and in that action, you can output the image contents.
This works (tested):
<img src="<%= Url.Action("ShowImage", "Image", new { Id = imageId }) %>" />