Error: Index was out of range. Must be non-negative and less than the size of the collection

n

nI was facing this error while editing pages in SharePoint sites, and was not able to figure out what’s going wrong ?

n

nBut finally figured out the solution after 1 day search

n

nThere are few checks you need to do to solve this

n

    n

  1. Check that page using correct page layout
  2. n

  3. Check that associated content type with page layout is correct
  4. n

  5. And most important : If there are some wrong / corrupted page layouts in the site’s master page gallery then delete them
  6. n

n

nSometimes we can’t delete those page layouts using UI, (at least in my case I was not able to do so ) so I written a simple console application to delete them and that’s all

n

nI hope this helps someone J

n

Leave a Comment