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

Ask A Question

Stats

  • Questions 210k
  • Answers 210k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer i have created pdf form to implement the same thing.… May 12, 2026 at 10:02 pm
  • Editorial Team
    Editorial Team added an answer There really is not mail queue in the Core framework.… May 12, 2026 at 10:02 pm
  • Editorial Team
    Editorial Team added an answer I will answer the question you have stated in title… May 12, 2026 at 10:02 pm

Related Questions

I am trying to deploy Sonar (automatic code monitoring tool) on a Jetty 7
So here I am, first time windows developer (done java swing, iphone, flash/flex) and
I'm using Mono 2.4 on the Ubiquity web hosting service. I created a simple
I've been waging a bit of a battle with MVC recently, trying to get

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.