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?



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?

  • 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

  • Yes i m modifying it with the SPwebConfigModification classes – sbtahir Apr 6 '10 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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