Welcome to Atalasoft Community Sign in | Help

Using SPWebConfigModification, Part 2 - Take this for example...

 

Take this for example...

 

You write a feature to be installed and you make web.config modifications that include adding a section.  Later, that feature is removed, and with it, your section.  Not a big deal, right?  Maybe not, it could possibly break the SharePoint installation because other features might be using that section!

I've thought, perhaps the SPWebConfigModification class is more powerful; that it wouldn't remove a section if something else put a child node under that section.  I decided to find out. 

I created two SPWebConfigModification objects, one that would create an <appSettings/> section as an EnsureChildNode type, and another with a bogus <add key="" value="" /> child, added them to the SPWebConfigModification collection, updated, applied and double checked those modifications made it all the way to the web.config.  I then got the existing <appSettings/> modification directly with SPWebApplication.WebModifications [0] and removed, updated, and applied the setting.  When I applied the modifications SharePoint complained in the same way if a section doesn't exist when you try to add a child (mentioned above).  So it's good to note that SharePoint will not remove the section if it has child nodes!

I’m now getting to be on the same page with everyone else, but not entirely; let me elaborate in Part 3.

 

Published Wednesday, October 08, 2008 1:08 PM by dterrell

Comments

Wednesday, October 08, 2008 1:17 PM by If you build it, They will come

# Using SPWebConfigModification, Part 3

We're in Part 3 of a 6 part blog post about the SPWebConfigModification object and my trials with it.

Wednesday, October 08, 2008 1:19 PM by If you build it, They will come

# Using SPWebConfigModification, Part 4

We're in Part 3 of a 6 part blog post about the SPWebConfigModification object and my trials with it.

Wednesday, October 08, 2008 1:21 PM by If you build it, They will come

# Using SPWebConfigModification, Part 5

We're in Part 3 of a 6 part blog post about the SPWebConfigModification object and my trials with it.

Wednesday, October 08, 2008 1:23 PM by If you build it, They will come

# Using SPWebConfigModification, Part 6

We're in Part 3 of a 6 part blog post about the SPWebConfigModification object and my trials with it.

Thursday, October 16, 2008 11:49 AM by DotNetKicks.com

# Using SPWebConfigModification, Part 2 -Take this for example

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Anonymous comments are disabled