Image Refresh Fails After FileUpload When Deployed to Server

Not panicking yet, but...  I have a simple aspx page with a FileUpload for saving and image file to a database.  The image is displayed using a Silverlight control (which is not important because it fails even if I use a plain asp:Image).  

After the user uploads the file, a button is pressed to Save it to Session.  Then a second save button is pressed to store it in the backend.  When the page is reloaded, the image is retrieved and saved to a 'cache' on the web server ( folder 'images').  A Uri is constructed for the file, which is then set to the source of the image embedded in the Silverlight control.  So the image control should be pointing to the file in the cache.

The peculiar thing is that this contraption works fine in Visual Studio 2010, but it fails when it is deployed to the server.  I suspect it has to do with the Server.MapPath line but I cannot prove it.  I observe that the file gets written to the physical server path, but I cannot see the file when I browse the web site within IIS7, so I also suspect the problem may have to do with my configuration of the IIS7 web site.
PIR.CS
DaveThePianoDudeAsked:
Who is Participating?
 
DaveThePianoDudeAuthor Commented:
Hi - thanks for the responses.  We decided to use Obout controls for displaying the image.
0
 
RouchieCommented:
I had a similar problem that was because the browser was caching the old image.  I solved it by adding no-cache rules to the page.  In your code it looks like the ImageUrl is constructed from a Session key, so that won't change as the user stays logged in, which means the browser 'thinks' its still getting the same image and has no idea about your back-end logic.
0
 
Johny BravoCommented:
Hi, don't know about silverlight, but if it is asp:image control, and if you are uploading and then setting that image to the control again, then the previous image is displayed. It is caused due to browsers cache functionality. If you press Ctrl + F5, does it show the new image?
If yes then the solution :  add timestamp to the image as querystring,
<img src="image.jpg?lastmod=11054524234">
then wehn you update the image timestamp will surely change and the image displayed is new one.
It worked for me. Hope you'll be benefitted
0
 
DaveThePianoDudeAuthor Commented:
Thanks to everyone who submitted an answer.
0
 
DaveThePianoDudeAuthor Commented:
In the end, it was easier to just use Obout for displaying the image.  It is both simpler and more reliable.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.