More in this section

Forums / Developing with Sitefinity / caching user controls

caching user controls

9 posts, 0 answered
  1. Kevin Pipher
    Kevin Pipher avatar
    91 posts
    Registered:
    30 Nov 2005
    22 Aug 2008
    Link to this post
    Hi all,

    Has anyone run into exception issues with cached user controls when editing pages in sitefinity?

    I have a simple user control (contains a panel and a set of hyperlinks), which sits on my master page and is cached using outputcache declaration (in the usercontrol):

    1<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TopicsPopDown.ascx.cs" 
    2    Inherits="UserControls_Menus_TopicsPopDown" %> 
    3    <%@ OutputCache VaryByParam="none" Shared="true" Duration="1800" %> 


    Periodically, when in the Pages module and clicking the "edit this page" button, I get the exception below.  the control 'pdmTopics' is the user control located within the master page. There is only a single instance of the control on the page.

    Just wondering if anyone has ever run into the same exception when using caching with Sitefinity. 

    TIA,

    Kevin.

    Multiple controls with the same ID 'pdmTopics' were found. FindControl requires that controls have unique IDs.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Multiple controls with the same ID 'pdmTopics' were found. FindControl requires that controls have unique IDs.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Multiple controls with the same ID 'pdmTopics' were found. FindControl requires that controls have unique IDs.]
    System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +220
    System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +280
    System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +280
    System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +280
    System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +280
    System.Web.UI.Control.EnsureNamedControlsTable() +57
    System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +106
    System.Web.UI.Control.FindControl(String id) +9
    Telerik.Cms.Web.UI.ControlHelper.FindControl(Control control, String controlID) +224
    Telerik.Cms.Web.UI.Toolbox.BindToToolBar() +84
    Telerik.Cms.Web.UI.Toolbox.LoadZones() +125
    Telerik.Cms.Web.UI.Toolbox.CreateChildControls() +1897
    System.Web.UI.Control.EnsureChildControls() +87
    Telerik.Cms.Web.UI.Toolbox.set_Expanded(Boolean value) +31
    Telerik.Cms.Web.UI.ToolBar.ExpandToolbox(Boolean expand) +48
    Telerik.Cms.Web.EditPage.CreateChildControls() +941
    System.Web.UI.Control.EnsureChildControls() +87
    System.Web.UI.Control.PreRenderRecursiveInternal() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041


    Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    27 Aug 2008
    Link to this post
    Hello Kevin Pipher,

    We were not able to reproduce the problem by adding OutputCache to a control used in Sitefinity. Is it possible to send us your control and masterpage, so we could see this behavior locally? You could open a new support thread and attach the control to it.

    Regards,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Shane
    Shane avatar
    28 posts
    Registered:
    27 Jul 2008
    29 Sep 2008
    Link to this post
    Hi Telerik team,

    I am also currently getting this issue when I cache my chrome controls (header, footer, navigation).

    I am currently unable to implement this approach until I find a solution.

    I'm looking at a way I can get the latest version when in edit mode so I am not getting the cached version?

    Help please?

    Was there an answer in the end?
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    02 Oct 2008
    Link to this post
    Hi Shane,

    We have again tried to reproduce this problem. Since it was not  successful try, we would kindly ask you for the same - if it is possible to send us your control and master page. You could open a new support thread to do so.
    We apologize that could not help you right away, but we will give our best to resolve the problem.

    Thank you for your cooperation.

    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Sam
    Sam avatar
    10 posts
    Registered:
    29 May 2008
    05 Nov 2008
    Link to this post
    I tentatively believe that I have a fix for this.
    Instead of using a declarative outputcache at the head of the ascx:
    <%@ OutputCache VaryByParam="none" Shared="true" Duration="1800" %> 


    Instead, do it programmatically on the Page_Load in the code behid:

            Response.Cache.SetExpires(DateTime.Now.AddSeconds(900));  
            Response.Cache.SetCacheability(HttpCacheability.Server);  
            Response.Cache.SetValidUntilExpires(true); 


    This seems to be making SiteFinity happy on the admin side, while still giving me the  caching I need.
    Please chime in and let me knof if this worked for you as well. Hopefully it's still in time to be of aid.
  6. Sam
    Sam avatar
    10 posts
    Registered:
    29 May 2008
    06 Nov 2008
    Link to this post
    An update to what I posted before.
    Still in the Page_Load, but instead use this:

    this.CachePolicy.Duration = new TimeSpan(0, 15, 0); 

    The above code, glomming on to the page's response, caches every page the control is on.
    The new code, anchored to the Control scope of "this" caches just the control.
  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Nov 2008
    Link to this post
    Hi Sam,

    Thank you very much for sharing your solution with the community. We appreciate it and updated your Telerik account for that.

    Regards,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Shane
    Shane avatar
    28 posts
    Registered:
    27 Jul 2008
    10 Dec 2008
    Link to this post
    Hi Guys,

    I have been asked again to look at the caching options when using Sitefinity.

    The InDatabase option looks the best for us (web farm). I have tested it and it works well with initial testing.

    However, I require some parts of the page to reflect current state. An example of this is if the user is currently logged in or not.

    How do I achieve this? Is there a way to only cache controls, or explicity remove particular controls?

    If not I need to implement .Nets standard outputcache (and implement a way to dump the cache from each server in our farm). That's fine - but i am still getting the error mentioned ealier? The solution Sam suggested didnt work for me.

    Help me please, any suggestions,

    Thanks,

    Shane
  9. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    11 Dec 2008
    Link to this post
    Hello Shane,

    We are going to provide this functionality out of the box with our next release. You will be able to create controls which will remain un-cached even if they are put on cached page.

    For more information on the upcoming release, please refer to Sitefinity 3.6 announcement.

    All the best,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
9 posts, 0 answered