Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
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 22-Feb-13 0:22am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
shabarnadh.vempati at 22-Feb-13 7:37am
   
Thank you, But why the usercontrol is null? how can I set Feed property , being null?
Ankur\m/ at 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.
shabarnadh.vempati at 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.
shabarnadh.vempati at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100