473,569 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebControl/Cache-Control question

Hi,

I am new to WebControls, I have created a WebControl that is used to present
an image, the image bing presented is created on runtime, each client side
button click causes the image to change, this require to prevent this image
from being cached, I have tried to play around with:
Context.Respons e.AddHeader("Ca che-Control", ... )
and with
Context.Respons e.Cache.SetCach eability(System .Web.HttpCachea bility.NoCache)
BUT Still, the image is being extracted from the cache and the changes
cannot be seen...

What am I doing wrong here?
How can I prevent the image from being cached?

Any help, samples or pointers will be appreciated.

--
Nadav
http://www.sophin.com
Nov 16 '05 #1
2 4080
"Nadav" <Na***@discussi ons.microsoft.c om> wrote in message news:9E******** *************** ***********@mic rosoft.com...
How can I prevent the image from being cached?


What you describe sounds like the correct means of preventing caching by
the user agent, provided the user agent understands the header.

The only thing I'd check is that you're setting this on the correct HTTP re-
sponse, that is, the one generating the dynamic image (i.e., I presume else-
where in the same web control you're also setting the HTTP Content-Type
header to something like image/png or something.) The cache-control
won't apply to the image if you're setting it on the HTTP response for the
page as a whole, or if the image is just an <IMG SRC="myimage.pn g" />
tag that's been rendered. In this situation, the user agent makes two requests,
one to grab your page containing the <IMG> tag, and then a second request
for the .png file specified in that <IMG> tag. If you set cache-control on the
page to expire immediately, then that doesn't affect the request/response for
the .png file directly (because that response doesn't have a cache-control on
it). I'm only speculating about what your situation looks like here, it's really
two entirely different scenarios: (a) a WebForm producing a dynamic image
with Content-Type: image/png (or other graphics file format), vs. (b) a Web-
Form with a WebControl producing an <IMG SRC="myimage.pn g"/> tag
where the browser makes a second request that's separate to fetch the image.

One tool that you may try is the power toy, Fiddler, described in this article
and a free download from MSDN,

http://msdn.microsoft.com/ie/default...trofiddler.asp

Check that the browser is receiving the Cache-Control HTTP header on the
request for the image.

Another place to check potentially are the IIS logs which you can usually find in the,

C:\WINDOWS\SYST EM32\LOGFILES\W 3SVC1

directory on the web server. If the request coming in for the image was responded
to with an HTTP Status Code 304, then IIS told the browser that the image
requested hasn't changed (based on its timestamp) and the browser should get
it from its cache.
Derek Harmon
Nov 16 '05 #2
>BUT Still, the image is being extracted from the cache >and the changes
cannot be seen... I don't understand what you are trying to do. Please explain some more. Are
you trying to cache the control or not? Why do you need to uncache on each
client click?

setcachability is being passed the wrong param. you need to pass nocache on
server and client. (don't remember which setting it is off the top of my
head)

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_______________ __________
"Nadav" <Na***@discussi ons.microsoft.c om> wrote in message
news:9E******** *************** ***********@mic rosoft.com... Hi,

I am new to WebControls, I have created a WebControl that is used to
present
an image, the image bing presented is created on runtime, each client side
button click causes the image to change, this require to prevent this
image
from being cached, I have tried to play around with:
Context.Respons e.AddHeader("Ca che-Control", ... )
and with
Context.Respons e.Cache.SetCach eability(System .Web.HttpCachea bility.NoCache)
BUT Still, the image is being extracted from the cache and the changes
cannot be seen...

What am I doing wrong here?
How can I prevent the image from being cached?

Any help, samples or pointers will be appreciated.

--
Nadav
http://www.sophin.com

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1643
by: Owatona | last post by:
Hi to all... I have 3 classes derived from webcontrol. I the first i have two dropdownlist, in the second i have some buttons, and the third its the webcontrol that are instanciate the two first... I would like to know what is the best way to comunicate elements that are placed in differents webcontrol... for instance... if i have a...
0
1018
by: chris | last post by:
Hi there, I have a webcontrol which should function like a button. Could I add an click action to the webcontrol (like you have ot on a button) or can I add an event handler to the webcontrol? Thanks a lot for your help Chris
3
3596
by: Mike Owen | last post by:
I have just tried to open a the file "Controls/CreateEditPost.cs" from within Visual Studio .Net, and the error message: 'An error occurred while loading the document. Fix the error, and then try loading the document again. The error message follows: An exception occurred while trying to create an instan of...
2
5906
by: Novice | last post by:
I can't seem to get my Custom WebControl to output a button whose click event is associated with a particular method. Here is the code I have right now that contains a panel and there is a button in that panel that should be associated with a event method - but it isn't working: protected override void Render(HtmlTextWriter output) {...
3
1444
by: spmm# | last post by:
Hi! Could someone please help me with the following; I have a WebControl that basically looks like this: public class LeftMenu : System.Web.UI.WebControls.WebControl { private string m_CurrentNodeId = string.Empty; public string CurrentNodeId
4
1328
by: Cesar Ronchese | last post by:
Hello. I have a WebForm that contains a Panel object. This panel, at design time is empty. When running, I need to create dinamically a Label and a WebControl (built from the same project). I can create the label and the webcontrol dinamically with no errors, but only the Label appear in the panel when the page is shown in the client...
4
7487
by: Christian Hofmann | last post by:
Hello, How is it possible to use a hyperlink webcontrol inside a label webcontrol? I am using resources for globalisation. Now I have a text like this: Please click here to open that document. "here" would be linked and should be a hyperlink webcontrol. But that is not possible.
2
2534
by: Peter Rilling | last post by:
Okay, I something weird is happening where I do not know if I am doing something wrong. I have a page that contains a custom webcontrol that I developed. This webcontrol basically loads a UserControl (ascx) using the LoadControl method and writing it out to the browser. Page --> custom webcontrol --> usercontrol (via LoadControl) -->...
2
1679
by: Peregrin | last post by:
Hello world. I will try to explain my problem. I've a webcontrol with an interface which provides a choice of methods. After including the webcontrol in a special aspx page, I want to call an interface webcontrol method from a javascript function part of special aspx page. But I don't know how to call a public webcontrol method from a client...
2
1153
by: Peter van der veen | last post by:
Hi I want to download files from a webserver. Normally a user goes requsta file, files in the login information and gets an "sava as' dialog. I want to automate this. With the use of a webcontrol i can easily fill in the login form and submit that to the server. The webcontrol comes then with the save as dialog.
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.