As per my understanding SPWebConfigModification class modifies the web.config across the farm, including all WFE. Are there any workaround to set some WFE specific web.config setting, like licence key or something using the above class

2 Answers 2


if (SPServer.LocalServerRole == SPServerRole.WebFrontEnd) { // Do your magic }


  • is there any way to identify the different WFE?
    – user4205
    Apr 9, 2012 at 9:33
  • Itereate through SPFarm.Servers and pick up all that matches (SPServer.Role == SPServerRole.WebFrontEnd) Apr 9, 2012 at 9:58
  • @SharePointDude, the problem is that SPWebConfigModification modifies web.config in all WFEs, @user4205 wants to modify only in specific. Apr 9, 2012 at 12:35

I politely disagree with SharePoint Dude because using SPWebConfigModification class requires submitting the modifications to the Content Service which applies the modifications across all web applications. That approach wont work.
I would suggest using a something external to SP to modify the web.config in that approach, i.e. PowerShell remoting and then transform the web.config file using WebConfigurationManager class directly.

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.