SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a class that parses an xml file and then adds the appropriate modifications to the web.config in my SharePoint 2010 web applications. When a feature is activated the proper mods are added to the web.config and when it is deactivated or uninstalled the mods are retracted.

In my xml I have about 9 nodes that are marked EnsureSection so I can be sure that some of the elements I need for example and are in the web.config. I do not retract these nodes when a feature is deactivated since I don't want to interfere with someone else using those nodes in the application.

Today I was poking around with PowerShell and I noticed that when I get the web application contentservice and look at the WebConfigModifications collection in memory; the mods that are for ensuring sections have been replicated in the collection. They have been replicated the number of times that I have activated the feature from the Central Admin.

I have code that wraps the adding of the mods so if they are already present in the collection I do not re-add them. I do not understand why the items that I have marked as EnsureSection are being replicated in the collection. Does anyone know why those mods would be getting multiplied like that?

share|improve this question
Not that this comment is the least bit constructive, but this sounds like one of the problems people generally have with SPWebConfigModifications - it's duplicating of entries even when you tell it not to do so. – James Love Mar 20 '13 at 19:47
Indeed. I could not figure out how to stop this so we have switched over to a pure powershell solution for our entries. We are in a multi-tenant farm so we can't just wipe the collection each time which is what I was doing before. – Maxmanzero Jul 17 '13 at 16:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.