Hello - I just posted this message in a different group, before I
found this much more specific group. I've seen similar questions, but
have yet to find a working answer.
-----------------------------
Can anyone help me with the following issue? I am STUCK. I'll make
this as basic as I can... I have an ASP.Net admin page that allows
users to post images to the server, and the images are displayed as
thumbnails on the same page. So, if you post a new image for
'Image1', the image is uploaded on button click, and the user then
sees their image in the appropriate spot below. Clicking on the image
fires off to a page that deletes the image, and the returns the to the
upload page, where their image placeholder is now empty. So far, so
good... Here's where my problem occurs - if I delete an image, and
then add a new one right behind it, they keep the same name. (Has to
be done this way). So, if I upload a picture of a football for 'Image
1', it will save as image1.jpg. If I then delete it and add a new
'Image 1' (say a basketball), it is the NEW image1.jpg.
The issue occurs when I delete an image, and replace it. On postback,
the OLD image is showing, even though the new image is what displays
in the file structure. (Example - post football, delete football,
post basketball, football is showing...) If I hit refresh, I then see
the new image, but this is not acceptable. I need the new image to
show immediately upon postback after uploading.
There's the background - I am fairly certian this is a caching issue.
I have:
added : Response.Cache.SetCacheability(HttpCacheability.NoCache); to
the PageLoad, with no luck.
added: <%@ OutputCache Duration="1" Location="none" VaryByParam="none"
%> to the aspx page in the header, with no luck.
Shut down the computer and tried again, with no luck.
Emptied my cache - no luck...
Finally, I went to my Internet Options in IE and set pages to 'Check
for Newer Versions of Stored Pages' every time - and this DID work.
However, I can't tell all of my users to do this.
So, I did get something to work, but that won't cut it. I need to
somehow get the exact same functionality by using code. Everything I
know of (mentioned above) is not working... Is there anyone out there
who can help me out? I am at my wits end over this!!!!
Thanks,
Ryan
Joerg Jooss - 22 Sep 2004 10:37 GMT
> Hello - I just posted this message in a different group, before I
> found this much more specific group. I've seen similar questions, but
[quoted text clipped - 44 lines]
> know of (mentioned above) is not working... Is there anyone out there
> who can help me out? I am at my wits end over this!!!!
Are these images referenced through simple image tags? In this case, making
the page itself non-cacheable (a must have for most web apps anyway) isn't
sufficient, because the images are fechted as separate entities. What you
need to do is make these images non-cacheable themselves -- either by
configuring the web server to mark all images non-cachable, or by decorating
the image URLs with dynamically changing parameters:
public class ImageForm : System.Web.UI.Page {
protected System.Web.UI.HtmlControls.HtmlImage image;
private void Page_Load(object sender, System.EventArgs e) {
// Guid used for demonstrational purpose only -- a tad too long
// for real world apps ;-)
string tag = String.Format("?{0}", Guid.NewGuid());
this.image.Src += tag;
}
}
Note that this is an awkward solution that is completely ignoring any HTTP
caching mechanisms and will always refetch any image regardless whether it's
necessary or not.
To get the proper HTTP behavior working, it's much better to mark the images
with a Cache-Control: no-cache, and make sure that with every image update,
the image's last write time is updated as well.
Cheers,

Signature
Joerg Jooss
joerg.jooss@gmx.net
rtmc - 22 Sep 2004 22:40 GMT
Jeorg - THANK YOU! I created a random number :
string Random = DateTime.Now.Ticks.ToString();
and appended it to the end of each image name - no more cached images!
Thanks again, this is a huge relief...
Ryan
Joerg Jooss - 23 Sep 2004 08:30 GMT
> Jeorg - THANK YOU! I created a random number :
>
> string Random = DateTime.Now.Ticks.ToString();
>
> and appended it to the end of each image name - no more cached images!
> Thanks again, this is a huge relief...
Sure it works ;-)
But as I said, this a rather naive solution. HTTP has everything to make
this work in cache-friendly fashion.
Cheers,

Signature
Joerg Jooss
joerg.jooss@gmx.net