I'm trying to add a section into the web.config of a SharePoint 2010 application and I created a webconfig.myname.xml in the \14\CONFIG folder. I then ran the following command to apply the changes:

stsadm -o copyappbincontent

The content was added TO ALL web applications config files.

I don't want that, I just want it for one web application.

How can I do it? I think its possible to do it programmatically but that involves writing the XML in code and I don't really like it.

P.S. Also, a thing that's not clear is what should be myname in webconfig.myname.xml? The solution name, the application name? (I'm currently using the solution name).

  • SPWebConfigModifications are the way to go. Yes that means you will need to specify your XML within your code...
    – Dennis G
    Nov 21, 2011 at 13:16

3 Answers 3


Check this out : http://stsadmwebconfig.codeplex.com/


I eventually used a programmatic approach and created the necessary steps in code, but by having the modifications serialized/deserialized in/from a XML file similar to web.config.


The myname in the file name could be whatever you want, SP will look at supplemental file (webconfig.*.xml) in the CONFIG folder. Make sure it's unique to avoid any conflicts with others solutions.

We currently use a programmatically approach for this and we have some issues with the ApplyWebConfigModifications() function. One of them is the one you described, when we apply a web config modification to the WebApplication directly, it apply it to all WebApplication.

  • You apply the web config modifications directly to the collection of WebConfigModifications of the web application?! msdn.microsoft.com/en-us/library/… Why do you say you can't specify a WebApp?
    – Dennis G
    Nov 21, 2011 at 13:15
  • @moontear , sorry, yes you can apply directly to the WebApplication, but it will be applied to all Web Application config files. I've updated my answer. Nov 21, 2011 at 13:21
  • No it will not be applied to all web applications, that doesn't make sense. When I add something to the WebConfigModifications of WebApp1, my WebApp2's web.config remains unchanged. What does happen is that SharePoint updates the web.config of WebApp2 (i.e. it saves it), but there are no changes from WebApp1 in WebApp2's web.config.
    – Dennis G
    Nov 21, 2011 at 14:56
  • @moontear, in our scenario it apply to all web.config. Microsoft Support have acknowledge this situation, but I assume we are doing something different fron typical scenario. Hope it will work for JohnDoDo Nov 21, 2011 at 15:18

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.