I would create a Http Handler to do this. Some browser support writing out images binary in the mark-up, but this is non-standard so I would recommend against it.
If you can get bytes from your query do something like this:
Then create the handler.
public class IISHandler : IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/jpeg";
myent logo = new myent();
var query = (from p in logo.tblLogoes
where p.Id == id && p.Id2 == id2
select p.Image).First();
byte[] bytes = query.bytes;
context.Response.OutputStream.Write( bytes, 0, bytes.Length);
}
}
Register the handle:
<system.web>
<httpHandlers>
<!-- ImageHandler handlers -->
<add verb="*" path="myimages/*.jpg" type="namespace.IISHandler, namespace" />
</httpHandlers>
...
On your webpage let the <img>
tag point to the handler.
<img src="myimages/someimage.jpg">
Your code shows little about how you target images, id's, name's? Most likely you want to pass in some identifier to the handler, so you can serve up the right image.
Take a look at http://msdn.microsoft.com/en-us/library/ms972953.aspx for a more in-depth sample on serving dynamic content with http handlers.