How to debug invalid markup in a template?
I've created a template (from the Sitefinity backend) and a few of pages based on that template. At some point I changed the template and saves/published the modifications. Now, when I open the template I get a yellow screen of death that says:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index]
System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +11236150
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4185
I suppose the Sitefinity template designer generated invalid markup somewhere (see the ProcessMisplacedControls method).
How do I investigate this this and how can I repair my template? Can I see the template markup somewhere to try and fix it manually?
The ProcessMisplacedControls method is not related to invalid markup. It is always called and is related to the logic of assembling the controls of the page. So, there is nothing wrong with it.
Are you using custom layouts or custom controls? Do you remember what you changed in the template before it gets broken?
Maybe you could try to change the template of the pages to a different one and reorder the controls manually? The template is not stored as markup and is deep in the database, so manual fix would need very good understanding of the database relations.
So what you are saying is that once a template is broken, there is not way to fix? That means I'll need to take database backup every time I'll change a template if I don't want to lose my work.
Well, a template is not supposed to break in the first place. Everything is stored in the database and we use an ORM library so it is not a simple thing to see why a template is broken. We can do it, we have the source code and all the understanding of the DB relations, you may be able to do it somehow, but it's not something that is supposed to be doable by third party. Frequent backups are always recommended.
Anyway, I wasn't able to reproduce the problem, but I reviewed the code in the method that throws the exception. I changed something that could probably cause this, this change will be available in the Q1 release.
I hope that this helps and I am sorry for the inconvenience.
Ok, thank you.
Have this same issue ver 4.2 was there a hotfix released?
Type : System.ArgumentOutOfRangeException, mscorlib, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Index must be within the bounds of the List.
Parameter name: index
Source : mscorlib
Help link :
ParamName : index
Data : System.Collections.ListDictionaryInternal
TargetSite : Void Insert(Int32, T)
Stack Trace : at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)