Gal Ratner
Gal Ratner is a Techie who lives and works in Los Angeles CA and Austin TX. Follow galratner on Twitter Google
How to modify AppSettings configuration values from your app code

You can easily change any AppSettings value in web.config during runtime from your C# code by using WebConfigurationManager.

Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");

AppSettingsSection appSettings = (AppSettingsSection)configuration.GetSection("appSettings");


if (appSettings != null)


   appSettings.Settings["SetupRan"].Value = "true";




This will set SatupRan to true in web.config


    <add key="SetupRan" value="true"/>



WebConfigurationManager Provides access to Web application’s configuration files and the GetSection methods can be used to get any section in web.config.

Posted 21 Nov 2009 6:22 AM by Gal Ratner
Filed under: , ,

Powered by Community Server (Non-Commercial Edition), by Telligent Systems