Weird Browser Request

J

Joe Fallon

I have a page in ASP.Net 1.1 which contains an image control.

I set the ImageUrl property = "MyImageViewerPage.aspx"

This page acts as an image handler. I have an array of bytes which I send to
the browser using BinaryWrite.

e.g. Response.ContentType = mVar.contenttype
Response.BinaryWrite(mVar.MyBytes)

This all works great.

The problem is that if I request the main page using 2 different links I
sometimes get the wrong image.
But other times I get the right image. There is no pattern to this.

What I have found is that if I set a break point in page load of my image
handler page that it does not always get called. I confirmed this behavior
using Fiddler.

When I call the main page and I get the right image, Fiddler shows 2
requests - one for the main page and one for the image.

When I call the main page and get the wrong image, Fiddler only shows a
single request for the main page.
(Note the wrong image is just the image from the previous request that
worked. The rest of the data on the main page changes to the right record -
but since the image handler never gets called the old image is now shown on
the page.)

The question is - why does my browser not request the image handler page
every time?
I have even tried hardcoding it using an html control instead of an asp
control. No luck.
(BTW - both pages have expires = -1 in Fiddler.)

Thanks for any ideas.
 
B

Bruce Barker

the browser and proxy servers cache the images. set the page to expire, or
better yet decorate the url with an image id (then you get the caching if
they return to an old page).

-- bruce (sqlwork.com)
 
J

Joe Fallon

Bruce,
Thanks for the quick response.

I have this code in both the main page and the image handler page:

Response.Buffer = True
Response.ExpiresAbsolute = Now().Subtract(New TimeSpan(1, 0, 0, 0))
Response.Expires = 0
Response.CacheControl = "no-cache"

So I would think that there is no caching going on.
Also, Fiddler does not show a 302 for the image when it is cached - there is
no request for it at all.
 
J

Joe Fallon

Bruce,
I used your idea of adding an imageID to the querystring and now it works.

I set the ImageUrl property = "MyImageViewerPage.aspx?imageID=123"

Thanks for the advice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top