Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug this error: Multiple controls with same ID 'ctl00$ctl00$ctl34' were found

Tags:

asp.net

For literally years, my website has very intermittently thrown the following exception:

Multiple controls with the same ID 'ctl00$ctl00$ctl34' were found. Trace requires that controls have unique IDs.

at System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize, Int32 controlStateSize)

at System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState)

.... etc (entire stack trace is within System.Web namespace)

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Sometimes a user will go to a page and this exception will be thrown - it happens on different pages and different control ids show up. Often, reloading the page will work. Other times, the exception will persist for a few refreshes before fixing itself.

Now I know that this error usually occurs when you are adding dynamic controls to a page and you accidently use the same ID within the one naming container, so I understand the meaning of the error.

But on my site, I am not adding dynamic controls. At least not that I know of.

I am running third-party components like Umbraco, Telerik and Peter Blum, and they are almost certainly adding control dynamically to the control tree at times, but, like I said, this error has been around for years, across major versions of all of these modules.

The intermittent nature of the exception suggests some sort of multi-threaded timing issue or use of a random number somewhere. Who knows... I can't find the cause of it in my code.

So my question is - how could I go about debugging this issue, given that the entire stack trace is within the .NET framework?

like image 759
cbp Avatar asked May 01 '26 09:05

cbp


1 Answers

From my experience this happens when you update pages (files) on your server with out first open the app_offline.htm , and at the same time some user try to open your site.

Especial if you update the files from ftp (thats take some time) or when you upload only the aspx or only the code behind file.

So while you uploading the files, the asp.net trigger the compilation because he finds some different on file, but because the files are not fully updated, there is a mess up with the compiled dlls.

  • I suggest to first open the asp_offline.htm file.
  • I also suggest if you try to update only one or two files, then update them both aspx and code behind file.
  • If you see this problem a quick solve is to open the asp_offline.htm file, just open web.config, make a line and saved it, and remove asp_offline.html. That way you give a signal to update again the site and find all the changes.

Other possible way is to disable the optimize on compile and force him to compile most of the files, even tho I think that this trick not work on me.

<compilation optimizeCompilations="false">

Hope this help.

like image 193
Aristos Avatar answered May 04 '26 09:05

Aristos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!