views:

35

answers:

1

Hi,

This thing is driving me nuts. I have a UserControl that is called WebUserControl.

I need to cache this control, so I put the following in the WebUserControl.ascx:

<%@ OutputCache Duration="240" VaryByParam="FeedName" %>

Then I have the Default.aspx file in which I have:

      <div class="divInnerLeft" id="L1" runat="server">
            <uc1:WebUserControl FeedId="a1" ID="a1" runat="server" FeedName=""/>
       </div>
       <div class="divInnerMiddle" id="M1" runat="server">
            <uc1:WebUserControl FeedId="a3" ID="a3" runat="server" FeedName=""/>
       </div>

In the Page_Load event I set the FeedName property - according to the user preferences.

The problem is that after initially loading the page, the controls are generated OK. But then, in the Page_Load event they are not available again. So the a1 and a3 are null and I cannot set the FeedName for different user.

How to solve this?

Thanks!

+1  A: 

You realise that VaryByParam creates a new entry in the OutputCache for each varying parmateter set in the HTTP GET / POST QueryString.

Setting the FeedName property on the user control reference is not going to vary the cache for the user control.

What exactly are you trying to achieve in regards to caching here?

I think what you're looking for is VaryByControl

RPM1984