Re: image not rendered when expected
- From: "Bruce" <coding-r-us@xxxxxxxxxxxxxxxx>
- Date: Wed, 3 May 2006 20:26:48 -0700
Thank you to all three of you who gave answers!
You were right on. I tacitly assumed that the ASP.NET process would
magically do a mapping from my server file location to a URL in the HTML it
emits, but in retrospect that's probably not even feasible. I've got it
now.
Thanks, Bruce
"Göran Andersson" <guffa@xxxxxxxxx> wrote in message
news:eoq7BTvbGHA.3856@xxxxxxxxxxxxxxxxxxxxxxx
You are saving the image on the hard drive of the server. The browser
doesn't have access to read from the hard drive of the server.
You have to save the file in a folder in the web root, so that the browser
can access the file via IIS.
If you save the file to Server.MapPath("somefolder/image.gif"), it will be
saved in a folder in the web, perhaps something like
"c:\inetpub\wwwroot\mysite\somefolder\image.gif" It will be available to
the browser using the url "somefolder/image.gif".
Bruce wrote:
Although I have quite a bit of WinForms experience, I am new to ASP.NET.
So don't be surprised by the elementary question. :)
I am creating a webpage with a dropdown list that allows the user to
select an image from the list. Based on that feedback, the page calls a
web service to grab the requested image (based on an index from the
dropdown) and place it on the local file system. Then it is supposed to
update the Image control on the page by assigning a new path (via the
ImageURL method on the control). But the new image is never rendered.
See code snip below.
I verified that the file accessed from the web service was actually
placed in its target location.
Is there some equivalent operation to the "invalidation " of a control
that is done in WinForms to force a redraw? Else, what else might I be
missing?
Thanks, Bruce
-----------------------------------------------------------------
protected void ButtonShowImage_Click(object sender, EventArgs e)
{
long index;
byte[] bytes;
index = Convert.ToInt64( DropDownList.SelectedItem.ToString());
asset = m_ServerOld.GetAssetElements(index);
bytes = asset.fileImage;
string fullPath = @"c:\temp\" + asset.originatorName;
string fileSpec = fullPath + @"\" + asset.fileName;
DirectoryInfo target = new DirectoryInfo(fullPath);
if (!target.Exists) target.Create();
using (FileStream fs = new FileStream(fileSpec, FileMode.Create,
FileAccess.Write))
{
fs.Write(bytes, 0, bytes.Length);
}
// ImageBox.ResolveUrl(fileSpec);
ImageBox.ImageUrl = fileSpec;
}
.
- Follow-Ups:
- Re: image not rendered when expected
- From: Steven Cheng[MSFT]
- Re: image not rendered when expected
- References:
- image not rendered when expected
- From: Bruce
- Re: image not rendered when expected
- From: Göran Andersson
- image not rendered when expected
- Prev by Date: RE: image not rendered when expected
- Next by Date: Re: connection string problems with connectionString property of web.config
- Previous by thread: Re: image not rendered when expected
- Next by thread: Re: image not rendered when expected
- Index(es):