Interesting problem: Show image byte[] in web page
-
I've found a number of articles that deal with the general subject, but I haven't been able to find anything that quite answers my question. I'm storing small JPG images (in binary format) in Sql Server as part of a larger record. When I pull that record, I'm also pulling the image. I can, of course, convert that binary data into an Image object; at that point, though, how do I display that Image object on the web page with the rest of the record's data? Is there a server control that facilitates this? Thanks for your help!
-
I've found a number of articles that deal with the general subject, but I haven't been able to find anything that quite answers my question. I'm storing small JPG images (in binary format) in Sql Server as part of a larger record. When I pull that record, I'm also pulling the image. I can, of course, convert that binary data into an Image object; at that point, though, how do I display that Image object on the web page with the rest of the record's data? Is there a server control that facilitates this? Thanks for your help!
Hi there, In an ASP.NET application, you basically use the Image[^] server control or the
img
tag to display the image on the web page. So in this case, you'll have two options: + Save theImage
object to disk, and specify the path to the image in theImageUrl
property of the Image control or thesrc
attribute of the img element. + Specify a web page .aspx or a custom htpp handler .ashx in theImageUrl
property, and the web page or http handler is responsible for reading the image data and writing to the OutputStream of the Response object.