SharePoint 2010 >> Editing Output HTML >> Issues with page or master page render override

后端 未结 2 2039
梦毁少年i
梦毁少年i 2021-01-25 08:09

Ok. This is a big one. I\'ll try and explain my issue but let me know if you need more info.

I would like to alter the HTML that SharePoint 2010 generates. I\'m going t

2条回答
  •  孤独总比滥情好
    2021-01-25 08:52

    The problem is caused by something in the page interfering with the outputcache during render, and more specifically the behaviour of the PostCacheSubstitutionTextHelper class. Probably your call to Render above triggers this.

    The welcome.asxc control behaves approximately like this (pseudo sequence diagram):

    Page Render > Welcome.ascx Render > PersonalActions Render > PostCacheSubstitutionText.Render > PostCacheSubstitutionTextHelper.RenderAndRegisterSubstitutionCallbackHandler (new instance of)PostCacheSubstitutionText.Render(called in delegate and now writes to HtmlTextWriter) > PostCacheSubstitutionTextHelper. RenderAndRegisterSubstitutionCallbackHandler HttpContext.Response.WriteSubstitution(stuffFromNewInstanceOfPostCacheSubstitutionText)

    So enough with the sharepoint freakshow and over to the workaround:-)

    Try adding this to your welcome.ascx in the hive:

    // in bottom of directives in /CONTROLTEMPLATES/Welcome.ascx
    <%@ OutputCache Duration="1" VaryByParam="none" %>
    

    Notice that the Duration is set to 1 since 0 is not allowed for user controls. this leaves a theoretical possiblity for failure, but in our scenario it worked.

提交回复
热议问题