For convenience Sometimes we put some simple configuration information into the Web. config file. Put to appsettings add key value and other information.
var config= configurationmanager.appsettings["Minamount"];//Get value
Configuration CFA = webconfigurationmanager.openwebconfiguration ("~");
CfA. APPSETTINGS.SETTINGS.ADD ("Key", "value");//Add Value
CfA. appsettings.settings["Redrule"]. Value = "1";//Modify Value
CfA. Save ();//Saving
Configurationmanager.refreshsection ("appSettings"); Force refresh of configuration files
varconfig= configurationmanager.appsettings["Minamount"];//Get ValueConfiguration CFA = Webconfigurationmanager.openwebconfiguration ("~"); CfA. APPSETTINGS.SETTINGS.ADD ("Key","value");//Add ValueCfA. appsettings.settings["Redrule"]. Value ="-1";//Modifying ValuesCfA. Save ();//Save//configurationmanager.refreshsection ("appSettings");//force refresh of configuration files
MVC webconfig AppSettings Value acquisition, addition, modification implementation