views:

252

answers:

3

I have an app that pulls up an image for the given user ID. I have the image tag nested inside an update panel in an AJAX TabContainer control. I have the ImageUrl set to "~/ImageHandler.ashx" and the ImageHandler.ashx grabs the user's ID from the session variable userID.

My problem is this: When the first user is loaded the correct image is pulled, but subsequent users do not pull up a new image. The image from the first user remains. So it seems as though the imageUrl is set when the first user is loaded and not touched again. How can I get the image to update each time I pull up a new user?

+1  A: 

It sounds like your browser is caching. Perhaps try setting the ImageUrl to '~/ImageHandler.ashx?user=<%=userId%>' or something like that. I assume that your ImageHander.ashx will ignore the argument, but the browser will recognize that the URL is different, and so will try to fetch it again for each new user.

StriplingWarrior
That worked beautifully. I set the ImageUrl in the code behind with the url you suggested and it works perfectly now! Thank you so much!
swolff1978
A: 

Use FireBug to check if the new image if being requested. If not, then ensure that the image returned by ImageHandler.ashx is not cached. You can do this by looking at the header parameters in FireBug. You want the response to expire immediately, alternatively ensure it is set to no cache.

Different programming paradigms have different methods of setting the header. Also, by inspecting the Net traffic in FireBug, you will know the cause of the problem. A simple solution has already been suggested to use query parameters to make each call unique.

Ryan Oberoi
A: 

It helped me lot. I was having same problem. I was displaying image from mermorystream from session U just cleared cache & it worked.

Pragnesh Patel