Config Management - lost entries

Jan 12, 2009 at 12:48 PM
Edited Jan 12, 2009 at 1:13 PM

I have been using feature receivers to add assembly entries into the web.config of a MOSS site called http://NCCWEB/.
The site has been extended to a Internet zone under the URL
There is a host added under IIS for the NCCWEB site of

The installations happens when I install the features using solution packages.
The features are required for all zones.

The code for the installation is:

public override void FeatureInstalled(SPFeatureReceiverProperties properties)

SPWebService currentService = SPWebService .ContentService;

SPWebConfigModification assembly1 = new SPWebConfigModification ();

assembly1.Path = "configuration/system.web/compilation/assemblies" ;
assembly1.Name =
"add[@assembly=\"Ncc.Web.Applications.Consultations, Version=, Culture=neutral, PublicKeyToken=0ef81f173cf02209\"]" ;
assembly1.Sequence = 1;
assembly1.Owner =
assembly1.Type =
assembly1.Value =
"<add assembly=\"Ncc.Web.Applications.Consultations, Version=, Culture=neutral, PublicKeyToken=0ef81f173cf02209\" />";




These entries work and appear in the web.config when the feature is installed and are removed when the feature is retracted.

Using the Manage Configuration Mods feature posted on this site, none of these entries are displayed when I select the NCCWEB application.

However if I cange the code in the ManageConfigMods.aspx.cs file to:


SPWebService currentService = SPWebService .ContentService;
foreach ( SPWebConfigModification modification in currentService.WebConfigModifications)
//foreach (SPWebConfigModification modification in this.lstWebApps.CurrentItem.WebConfigModifications)

DataRow row = table.NewRow();


row["WebApp" ] = this .lstWebApps.CurrentId;


(I have left the original foreach statement in for a comparison.)

All of the web.config entries are now displayed displayed.

Am I adding the web.config entries in the right way?

Can anyone explain the differences between the SPWebService.ContentService.WebConfigModifications and the WebApplicationSelector.CurrentItem.WebConfigModifications please?

Jan 12, 2009 at 2:39 PM
Edited Jan 12, 2009 at 2:40 PM
I have just done some further investigating and it appears that using the SPWebService.ContentService will apply the configuration changes to every application and zone in the MOSS farm.

My Virtual farm has several unrelated site collections i.e. http://mysite, http://nccweb1, http://443 etc.
The assemblies entry was appearing in every web.config file.

There may be a use for this but it is not what I was trying to achieve here.

I will try to rewrite my feature code to use WebApplicationSelector.CurrentItem so that I can target a specific site collection and its related zones.

Is there a need for the Manage Configuration Mods feature to include the ability to read, add and delete modifications in SPWebService.ContentService?