tkaragiris posted on February 16, 2011 14:00

To change one of the appSettings values in your web.config through VB.net use the example below. Keep in mind when you do the save it will reformat you web.config and remove comments that have been inserted manually.
Sub ChangeSetting()
Dim Cfg As Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
Dim AppSettingSec As AppSettingsSection = Cfg.GetSection("appSettings")
AppSettingSec.Settings("CachemodeOn").Value = True
Cfg.Save()