Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 93955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:25:32+00:00 2026-05-10T23:25:32+00:00

So, I am trying to deploy a Web Application feature that updates the web.config

  • 0

So, I am trying to deploy a Web Application feature that updates the web.config using the WebConfigModifications collection. There is lots of information on doing this including all the issues you run into so I am very confident in the code but no matter what I try the config elements are not added to the web config. This works fine in the development single server environment but does not update in the Farm.

No errors, no log information no event messages …. nothing pointing toward why it will not update:

SPWebConfigModification appSettingModification = new SPWebConfigModification();
appSettingModification.Name = ‘add[@key=\’Key\’][@value=\’Value\’]’;
appSettingModification.Path = ‘configuration/appSettings’;
appSettingModification.Owner = ‘Owner’;
appSettingModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
appSettingModification.Value = __appSettingResource;

if (removeModification)
{
app.WebConfigModifications.Remove(appSettingModification);
}
else
{
app.WebConfigModifications.Add(appSettingModification);
}
app.Update();
app.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();

==============================

EDIT

I wanted to add to this based on a suggestion by drax to reflect the ApplyWebModifications method. This method is on the SPWebService that is in the Microsoft.SharePoint.Administration namespace in the Microsoft.SharePoint assembly.

One of the issues with using this method is that all web.config files are updated in the farm even if no modifications are actually being applied. This causes the app pools to be recycled even if you do not intend to update the web config. Reflection shows why this is happening and it is very annoying.

Inside the method is a short foreach loop:

foreach (SPWebApplication application in this.WebApplications)
{
application.ApplyWebConfigModifications();
}

It is looping through each of the web applications and calling an INTERNAL ApplyWebConfigModifications method on the web application objects. If they just made this method public then we would be able to call the method individually without affecting the app pool recycling on web applications that are not affected by our updates. Just sayin’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:25:33+00:00Added an answer on May 10, 2026 at 11:25 pm

    problem is propably in your call of ApplyWebCOnfigModifications() instead of:

    app.Farm.Services.GetValue().ApplyWebConfigModifications();

    use:

    app.Farm.Servers.GetValue<SPWebService>().ApplyWebConfigModifications();

    The second code actually calls service responsible for updating web.config files.

    Sidenote: This code will actually open all webconfig files in all webapplications installed on server/farm 🙂 but it will update just right ones. If you will use reflector to scan this method you will see some nice example of using foreach loop 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using IIS and trying to deploy a web application that needs authentication mode=Windows.
I'm trying to deploy a web application using MSDeploy, on Team Build in TFS.
Hi I am trying to deploy an application using webstart. I have a requirement
I'm trying to deploy to a slicehost slice using this config/deploy/production.rb file. I'm clueless
I am trying to deploy a web application to a remote server over which
I'm trying to deploy new web application in Tomcat 6.0, but whenever I click
I'm learning ANT and I'm trying to deploy a web application in tomcat 6.0.20
I am trying to deploy an ASP.NET 3.5 Web Application to my production server
I have a Web Application that I'm trying to move from Sun Application Server
I am trying to deploy a web application from my Eclipse to Jboss 6.x

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.