<appSettings>
<add
key="AppKey"
value="AppValue"/>
</appSettings>
using
System;
using
System.Configuration;
using
System.Web.Configuration;
namespace
SampleApplication.WebConfig
{
public partial
class webConfigFile
: System.Web.UI.Page
{
protected void
Page_Load(object sender,
EventArgs e)
{
//Helps to open the Root level web.config
file.
Configuration webConfigApp
= WebConfigurationManager.OpenWebConfiguration("~");
//Modifying the AppKey from AppValue to AppValue1
webConfigApp.AppSettings.Settings["AppKey"].Value
= "AppValue1";
//Save the Modified settings of AppSettings.
webConfigApp.Save();
}
}
}
Output of Root Level
Web.Config:
<appSettings>
<add
key="AppKey"
value="AppValue1"/>
</appSettings>