Update image path after postback

In my web application, I change the photo uploaded by the user, but the path to it on the server remains the same. Is it possible, after the postback, to force the browser to reload this photo. That's right, it still displays the old one. thanks for the help

+3
source share
3 answers

It looks like the browser is caching the image.

You can add a fake querystring argument with the current date time to the image source to force the browser to reload it every time the page loads.

Example:

Image img = new Image();
img.ImageUrl = "~/pathToNewImage?q"+DateTime.Now.ToString();
+1
source

It would be better if you use the AJAX file upload control AsyncFileUpload, as it will give you what you are looking for right now.

http://asp.net-informations.com/ajax/ajax-AsyncFileUpload.htm

0

, y , .

0

All Articles