RegisterRequiresControlState Error + Workaround

RegisterRequiresControlState Error + Workaround

May 02, 2008 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

Thanks to our great community we have discovered a hard-to-track bug that happens on websites with a greater amount of traffic. Since you may be experiencing this bug as well, we’ve decided to publish the workaround here on the blog as well as some background.

The error manifests itself every so often and the page you see looks like this:

Error screenshot

The background

The bug happens mostly on websites with higher amounts of traffic and it happens when the same page is requested concurrently, at the very same moment. The problem is in the fact that even though the two pages are running in separate threads, the cache of the page that was requested first (and I mean first as in “just a bit” before the second one) is valid for the second page. The cache of the second page should not be valid for the first page, because it should be thread dependent, but it is. The particular error happens then as the first page progresses through its lifecycle, the second one enters that very same lifecycle and we get the “RegisterRequiresControlState can only be called before and during PreRender”.

The workaround

  • Add App_Code folder in the root of your application. 
  • Add the following class in App_Code.
1 public class CustomPageHandler : Telerik.Cms.Web.InternalPage     
2 {     
3      protected override void OnPreInit(EventArgs e)     
4      {     
5        Nolics.ORMapper.Base.ObDataCache.Current = null;     
6                base.OnPreInit(e);     
7      }   
8 }     

  • Open ~/Sitefinity/cmsentrypoint.aspx file.
  • In the first line change the value of Inherits attribute from Telerik.Cms.Web.InternalPage to CustomPageHandler.
  • Restart your application.

The conclusion

We have already fixed this issue for the upcoming Service Pack 2, but we do understand this is a really big issue to some of you and we wanted to give you a workaround in case you need it right now or if you are not planning on upgrading to Service Pack 2 as soon as it is released.

We’d like to apologize to everyone who experienced the problem. We would also like to thank everyone who reported the issue and provided us with many details which enabled us to pinpoint this bug.


The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments are disabled in preview mode.
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

More From Progress
270x123_Sitefinity 12 Is Here Effortlessly Deliver Complex Customer Experiences
Sitefinity 12 is Here: Effortlessly Deliver Complex Customer Experiences
Read More
232x131_Protecting Against the 10 Most Critical Web Security Risks
Protecting Against the 10 Most Critical Web Security Risks (Infographic)
Read More
G2 Crowd Report: Sitefinity vs. Sitecore
Read More