More in this section

Forums / Developing with Sitefinity / VaryByCustom is already set

VaryByCustom is already set

4 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    09 Mar 2009
    Link to this post
    I am trying to optimize our SF CMS project as it is rather slow to load pages...

    First of all i am attempting to follow the example in this KB article: http://www.sitefinity.com/support/knowledge-base/kb-article/b1154K-bagb-b1154T-cgb.aspx but i am using SF3.6 and <cms> node of the web.config does not seem to be this way anymore... So... First question here is:

    1. Can someone please tell me how to enable InMemory caching int he web.config of version 3.6

    Now when i set caching on my home pages as i would like to do on most pages of the site i get the following error:

    Server Error in '/PFV3cms' Application.

    VaryByCustom is already set.

    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.InvalidOperationException: VaryByCustom is already set.

    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:

    [InvalidOperationException: VaryByCustom is already set.]
       System.Web.HttpCachePolicy.SetVaryByCustom(String custom) +3253560
       Telerik.Cms.Web.InternalPage.SetAspNetCachebility(CacheDependency dependency, ICacheSettings cacheSettings) +457
       Telerik.Cms.Web.InternalPage.Render(HtmlTextWriter writer) +486
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +667
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +2065883
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
       System.Web.UI.Page.Render(HtmlTextWriter writer) +26
       Telerik.Web.UI.RadAjaxPage.Render(HtmlTextWriter writer) +40
       Telerik.Cms.Web.CmsPageBase.Render(HtmlTextWriter writer) +30
       Telerik.Cms.Web.InternalPage.Render(HtmlTextWriter writer) +498
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1896
    


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




    2. Can someone please tell me what might be causing this, i have other pages the cache without this error...

    Duncan
  2. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    09 Mar 2009
    Link to this post
    The appears to be cause by a <rad:RadAjaxPanel> on one of the controls on the page...

    Removing the <rad:RadAjaxPanel> clears the error...

    How can i resolve this please....

    Duncan
  3. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    10 Mar 2009
    Link to this post

    Hi Duncan,

    Yes, the problem is related to the RadAjaxPanel, because it calls page rendering internally, which causes SetAspNetCachebility() method to be called twice when the page is set for caching. We will fix this issue in the upcoming service pack of v3.6.

    You can we can use the following work around:
    Create a class CustomInternalPage (inherited from InternalPage) in the App_Code:
    using Telerik.Cms.Web; 
     
    public class CustomInternalPage : InternalPage 
        protected override void SetAspNetCachebility(System.Web.Caching.CacheDependency dependency, Telerik.Caching.ICacheSettings cacheSettings) 
        { 
            if (!this.rendering) 
            { 
                this.rendering = true
                base.SetAspNetCachebility(dependency, cacheSettings); 
            } 
        } 
     
        private bool rendering = false
     

    And set the class as a code behind of ~/Sitefinity/cmsentrypoint.aspx page:
    <%@ Page Inherits="CustomInternalPage" MasterPageFile="~/Sitefinity/Dummy.master" %> 



    Best wishes,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    10 Mar 2009
    Link to this post
    Thanks Vlad,

    Problem solved! (love it when that happens)

    Duncan
Register for webinar
4 posts, 0 answered