I have some problems with the way I am showing the BLOB fields in the
Image web controls. It does work on my localhost though sometimes I
need to hit Refresh for the images to load properly. However, when I
try to access the same page from another machine or when I test the
code on a remote server the images just wouldn't show.
The page I am talking about has 3 Image web controls. In the
CodeBehind I am loading these controls by using an auxiliary aspx
page. The Code looks like this:
Main Page
=========
..
..
protected System.Web.UI.HtmlControls.HtmlInputFile banner1;
protected System.Web.UI.HtmlControls.HtmlInputFile banner2;
protected System.Web.UI.HtmlControls.HtmlInputFile banner3;
..
..
loadImage(ref imgMainBanner, "banner1");
loadImage(ref imgMainBanner, "banner2");
loadImage(ref imgMainBanner, "banner3");
..
..
private void loadImage(ref System.Web.UI.WebControls.Image imgControl,
string imageName)
{
imgURL = "GetImage.aspx?imageName=" + imageName;
imgControl.ImageUrl = imgURL;
}
GetImage.aspx
=============
string imageName = Request["imageName"];
byte[] b = businessRules.getImage(imageName);
if (b != null)
{
Response.Clear();
Response.ContentType = "image";
Response.BinaryWrite(b);
Response.Flush();
Response.Close();
}
Now here are my questions if you could kindly help me out with this:
1) Is there any other way to do this without writing the binary
contents of the BLOB into a physical file? I fear the administrators
wouldn't like the idea of end users writing files on the server any
time they hit this page.
2) Why would this solution work on my localhost (sometimes with the
help of the Refresh button) but not on remote servers?
3) Is it possible to create a file in memory and link it to the Image
web control? If so, how?
I would greatly appreciate your help on this issue. And be even more
thankful if you include some sample code.
Thanks!
Jose R. Castro