user1426684
user1426684

Reputation: 11

Programmatically add key in web.config for application deployed in web farm

How can I make the config.AppSettings.Add(key,value) to add new key on all boxes in a web farm Programmatically ?

Upvotes: 1

Views: 1442

Answers (1)

lcryder
lcryder

Reputation: 496

Here's some code to add or update a key:

Dim cfg As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(Configuration.ConfigurationUserLevel.None)

cfg.AppSettings.Settings.Remove(key) //Get rid of the existing value
cfg.AppSettings.Settings.Add(key, val)

cfg.Save(Configuration.ConfigurationSaveMode.Modified)

Upvotes: 2

Related Questions