Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have custom web.config functionality that uses Linq to merge elements into a web.config based on a template file. I would like to use this in a feature so I can get it to merge all web.configs in a load balancing environment. I know there is something called SPWebConfigModification, but the extent of the elements to add is large and I need it to be more dynamic like the template solution. I know I could run it on each front end server, but it would be better in a feature or solution.

Is there a way to get access to the web.config in a feature in SharePoint 2007?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

If you're really sure you don't want to use SPWebConfigModification, you could look at SPWebService.ApplyApplicationContentToLocalServer() - this has the capability of merging entire sections into config files, but has the following caveats:

  • Only applies to the local server (clue is in the name!)
  • Must be called by a local administrator

The combination of these two caveats means you can't use the normal pattern of using a timer job to ensure something executes on all servers in a farm. If you were happy to write say, a windows service which would call this web service, well that would get you round it.

However my recommendation would be to stick with SPWebConfigModifcation. Regardless of how big a custom section is, it's going into the web.config as a child node of a node somewhere so can be added as an 'EnsureChildNode'. It would certainly be possible to combine your merge functionality with SPWebConfigModification (i.e. pass in the merged XML to calls to SPWebConfigModification), and then you can be sure the change will applied across the whole farm. Also, it's easy to write code to remove the changes (e.g. in the Feature Deactivated event if your host code is a Feature receiver).

share|improve this answer
    
Thanks, it gave me an idea, I will try it out. If it works I will blog it. –  gaotter Jan 10 '10 at 9:37

Don't you have source code of the merger application ? I guess you may be able to use sharepoint api to access the web.conf file, including your code in a feature.

sounds interesting at least,

share|improve this answer
    
To merge it I using a MSI. It works but only if that MSI runns on all the fron end servers. –  gaotter Jan 8 '10 at 13:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.