I have a solution where I am including a webconfig.Name.xml modification file in the CONFIG mapped folder. The problem is, it is only applied if I add a post-build step of:

stsadm -o copyappbincontent

Which is not desirable. I was wondering if there is any other way, other than SPWebConfigModification?

Any best practices for this kind of work?


1 Answer 1


I think you can use the SPWebConfigModification without stsadm requirement. here is the example:

Lets say you want to change mode value to Off.

       <customErrors mode="On">

here is the code

private void SimpleSample()
     // Get an instance of my local web application
     SPWebApplication webApp = new SPSite("http://localhost").WebApplication;

     // Create my new modification to set the mode attibute to "Off".
     // Example: <customErrors mode="Off">
     SPWebConfigModification modification = new SPWebConfigModification("mode", "system.web/customErrors");
     modification.Owner = "SimpleSampleUniqueOwnerValue";
     modification.Sequence = 0;
     modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute;
     modification.Value = "Off";
     // Add my new web.config modification.
// Save web.config changes. 
     // Applies the list of web.config modifications to all Web applications in this Web service across the farm.

read more over here: How To: Modify the web.config file in SharePoint using SPWebConfigModification

Managing Web.config Modifications


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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