Welcome to Atalasoft Community Sign in | Join | Help

Using SPWebConfigModification, Part 6 - Putting it to work

 

Putting it to work

 

So, using this code, you could embed in your Feature receiver a web.config file that looks like the aforementioned fragment.  Read in the XML to an XmlDocument object, and then pass that XmlDocument along with your SPWebApplication or SPWebService’s WebConfigModification collection to a recursive starter method, like this:

private void AddModifications(XmlDocument doc, Collection<SPWebConfigModification> collection)

{

    XmlNode docRoot = doc.DocumentElement.FirstChild.ParentNode;

    SPWebConfigModification mod = new SPWebConfigModification(docRoot.Name, doc.DocumentElement.Name);

    mod.Sequence = _seq = 0;

    mod.Owner = _modificationOwner;

 

    AddChildren(collection, docRoot, mod);

}

Finally, be sure to apply those changes to the content service, and update the SPWebApplication or the SPWebService into which you’ve put those modifications:

SPWebService.ContentService.ApplyWebConfigModifications();

currentWebApp.Update();

I hope this helps everyone in their SharePoint tasks!

 

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

Comments

# If you build it, They will come : Using SPWebConfigModification, Part 1

Thursday, October 16, 2008 12:02 PM by DotNetKicks.com

# Using SPWebConfigModification, Part 6 - Putting it to work

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

Anonymous comments are disabled