May 14th, 2009 | No Comments

Following is the simple code to change the value of the appSettings key,

private void UpdateConfig(string strKey, string strValue)
{
Configuration objConfig = WebConfigurationManager.OpenWebConfiguration(”~”);
AppSettingsSection objAppsettings = (AppSettingsSection)objConfig.GetSection(”appSettings”);
if (objAppsettings != null)
{
objAppsettings.Settings[strKey].Value = strValue;
objConfig.Save();
}
}

Written by Ajay Matharu

May 14th, 2009 at 10:32 am