R – How to change SharePoint extended web application’s web.config file


Using the SharePoint API, how can I modify an extended webapp web.config file?

I have to do some changes in this file to specify the connection string, membershipprovider, etc… for using Forms Authentication.

Currently, I can change the "master" webapplication web.config file, but not the extended one.


I'm using Sp 2007. I'm already using SPWebConfigModification class to modify the parent webapp. Thoses modifications are propagated to the extended webapp. I have to change ONLY the extended one. But I don't find the way to do it.

What I'm trying to achieve, is to program a little wizard that:

  • Shows a WebApp list so the user can select one
  • Extend that selected webapp to a different zone
  • Configure that extended zone to use Forms Authentication


Best Solution

I got an answer form a blog.

In your case , you need to write a Web Application scoped feature which after you provision your site using your C# app, it is deployed to the newly-provisioned site and in the receiver of the feature you inject the required web.config settings because in that context configuration API is obtainable , but again bear the following in mind:

If you don’t use SPWebConfigModification class and either use ASP.NET 2.0 configuration API or your own mechanism , propagating changes across the farm is YOUR RESPONSIBILITY. If this happens on an standalone installation then you don;t need to be worried about this.

So it cannot be done externally. We have to do a feature in order to acheve this.


Related Question