+1-888-365-2779
Try Now
More in this section
Categories
Bloggers
Blogs RSS feed

RegisterRequiresControlState Error + Workaround

by Ivan Osmak

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 }     
9  

 
  • 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.

10 comments

Leave a comment
  1. Julia Essex May 02, 2008
    Which versions of Sitefinity does this apply to? Just 3.2 SP1? Or does it apply to earlier versions of 3.x?
  2. Bob May 02, 2008
    It applies to earlier versions as well.
  3. Seth May 03, 2008
    Hi Ivan, thanks so much for posting this as I have been waiting for a solution to this for a long time. Cheers.
  4. Zubair.NET! May 05, 2008
    That solves the problem, Thanks!
  5. Zack May 05, 2008
    Happy to be of help with details ... especially if it nets us solutions like this ;)
  6. Ivan May 05, 2008
    Hi Zack, that's how we roll :). We gather details, we try to figure it out, then we try to figure it out a bit more - finally we bring out big guns (read : Bob) and then we post the solution. Anyway on behalf of everyone in Sitefinity team - we are really glad we were able to solve this issue and that it was helpful to you.
  7. Jason M. Nov 01, 2008
    We're using 3.2 SP1 and this worked for our external page...but we're still getting this on the /sitefinity/admin/ side? Is there another fix for this? J
  8. Quade Oct 02, 2009
    Hi Jason
    we are using 3.2 SP2, and are getting exactly the same issue on the backend
    did you find a solution?
  9. Arun Garg Jan 23, 2012
    How can i use this code in my visual studio  2008 environment??
  10. Arun Garg Jan 23, 2012
    How can i use this code in my visual studio  2008 environment??

    Leave a comment