Home > Code > C# > Dynamically change the web.config file key value using C#.net

Dynamically change the web.config file key value using C#.net

by Narain Siddharth   on Dec 14, 2011   Category: C#   |  Views: 3434    |  Points: 25   |  Silver 



The below sample C# code shows how to change the key value of appsettings in the web.config file dynamically.


web.config file settings
<appSettings>
<add key="Time" value="10" />
</appSettings>

Namespace details
using System.Web.Configuration;
using System.Configuration;

code
Configuration AppConfigSettings = WebConfigurationManager.OpenWebConfiguration("~");
AppConfigSettings.AppSettings.Settings["Time"].Value = "10";
AppConfigSettings.Save();







Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts