views:

24

answers:

2

Hi all,

I created an image handler page which retrieves the physical path of an image on the local machine and then using filestream, resizes and displays it - using a integer (record id) passed as querystring.

What is happening is that, when the routine in pageload cannot find an image relating to the record id, it displays random images (from other records).

This only ocurrs when the related record id has no image. The routine assigns a default image if no image exists for the record, but instead of displaying the default image, the page is displaying images from other records. If I keep refreshing the page it displays different images from other records.

In my page load event, before doing anything else I have put:

Response.Cache.SetCacheability(HttpCacheability.NoCache)

But this has not changed the behaviour.

Any help appreciated.

thanks,

KS

A: 

Hi,

Perhaps you can try to disable caching for that specific page using the web.config: http://msdn.microsoft.com/en-us/library/ms178606(VS.80).aspx

Another option is giving a timestamp to your page (as querystring param). this way the cache will automatically be avoided.

Sem Dendoncker
Cannot set Duration property to zero, trying to find out how to disable it in web.config.
Perplexed
Ok, I worked out how to disable caching in web.config, but it has not changed the page behaviour :(
Perplexed
When testing in debugger, it returns the default image every time, but on web server it is showing those "cached" images.
Perplexed
ok, some progress (sort of!)I replaced the below code: PressID = Integer.Parse(Request.QueryString("vLink")) img = New common.RecordJPG(PressID) If img.JPG = String.Empty Or System.IO.File.Exists(img.JPG) = False Then imgFileName = "\\intmedweb\img\NotAvailable.gif" Else imgFileName = img.JPG End If
Perplexed
I replaced the line with the "NOtAvailable" image assignment with:Response.Redirect("http://www.myserver.com/img/notavailable.gif", True)And this beahves as expected. Question is - why does the above code not work?Why does ... imgFileName = "\\intmedweb\img\NotAvailable.gif"... not load the default image and display <sigh>
Perplexed
have you tried to load the byte array and printed that one on the screen?
Sem Dendoncker
No, have not tried that. Will try it out.
Perplexed
`"\\intmedweb\img\NotAvailable.gif"` is a path on the internal network, which is normally not available from the client browser. In your development environment, the internal network path is available, so there it works...
awe
A: 

You could handle the case in code so when no image is present, you display a static blank image instead.

awe
That is not the problem as I am already doing that.
Perplexed