Click here to Skip to main content
15,912,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a news ticker in web user control with news from different urls, the urls are passed to user control by a public property named Feed in the user control. I am using this user control in master page, I don't want it to be refreshed when ever content page is requested. So, I thought of caching, I tried it but, in the page load of my master.cs where I call this user control with some urls set to the Feed Property of the User Control, an exception is raised, the null reference,
I tried httpresponse.clearcacheitem(path), but still the control is null, I came to know that, the controls in the cache would be null,

But, my requirement is to refresh the cache based on the property , if the urls(WWW) in the 'Feed' property changes the cache should get refreshed, if not,the cached version has to be used with much delay in loading the page.


any suggestion is appreciated.

I can't use file dependency,
Posted

1 solution

You are looking for output caching. Read more about it here - @ OutputCache[^].

In your case, you will have to set VaryByParam attribute to Feed.

Read more about the topic and then try implementing it in your application.
 
Share this answer
 
Comments
[no name] 22-Feb-13 7:37am    
Thank you, But why the usercontrol is null? how can I set Feed property , being null?
Ankur\m/ 22-Feb-13 7:49am    
How are you calling your user control? Are you using FindControl() method? And master page directly wont have the user control. It would be present inside some of your aspx page which inherits the master page. So you will first need to get that page and then find the user control in it.
[no name] 22-Feb-13 23:38pm    
I tried with a sample application without master page, I registered the control in aspx page with a tag name and prefix , later in the pageload, I set the Feed property with urls, its working fine for the first time, from is postback, the user control is null.
[no name] 22-Feb-13 23:38pm    
I tried with a sample application without master page, I registered the control in aspx page with a tag name and prefix , later in the pageload, I set the Feed property with urls, its working fine for the first time, from is postback, the user control is null.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900