Solved

Image Refresh Fails After FileUpload When Deployed to Server

Posted on 2013-05-20
5
448 Views
Last Modified: 2013-08-07
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
0
Comment
Question by:DaveThePianoDude
  • 3
5 Comments
 
LVL 25

Expert Comment

by:Rouchie
ID: 39183870
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
 
LVL 8

Expert Comment

by:johny_bravo1
ID: 39240597
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
 

Accepted Solution

by:
DaveThePianoDude earned 0 total points
ID: 39376608
Hi - thanks for the responses.  We decided to use Obout controls for displaying the image.
0
 

Author Comment

by:DaveThePianoDude
ID: 39376612
Thanks to everyone who submitted an answer.
0
 

Author Closing Comment

by:DaveThePianoDude
ID: 39388526
In the end, it was easier to just use Obout for displaying the image.  It is both simpler and more reliable.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now