SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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've a SPJob Scheduled with a package (wsp) installation which update web.config and a Application Page which also build to update web.config.

The problem is when I install the package it successfully update the web.config. I've confirmed the changes. Now, when we go to our Application Page which also successfully update the web.config but I lost the changes made during package installation.

Any idea what would I be doing wrong?


share|improve this question

Could it be a clash of 'Owner' of the SPWebConfigModification? If both sets of code are using the same value, one could remove entries which were actually added by the other. A best practice is to use something tied to the class name for the 'Owner'.

Alternatively, are you merging the config changes in rather than adding nodes? If so, could something be going wrong there e.g. you're merging into the wrong place in the XML tree?

share|improve this answer
No, both sets of code are not using the same values. and we are not merging the web.config , we are adding the nodes. – sbtahir Apr 6 '10 at 11:39
I think you might need to post the code somehow for us to diagnose further.. – Chris O'Brien - MVP Apr 6 '10 at 15:01
// Add all modifications. foreach (ModificationEntry modEntry in _modifications) { webApp.WebConfigModifications.Add(CreateModification(modEntry)); } // Apply them via the farm's web service. webApp.WebService.ApplyWebConfigModifications(); – sbtahir Apr 7 '10 at 7:50
Any Idea why that's happening – sbtahir Apr 8 '10 at 11:36

How do you update the web.config?

The supported way to do it is by using the SPWebConfigModification classes

share|improve this answer
Yes i m modifying it with the SPwebConfigModification classes – sbtahir Apr 6 '10 at 11:01

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.