How to change the key value present in web config dynamically
Learn how to change the key value present in web config dynamically, in this article you will know Dynamically change key value in web.config.
Dynamically change key value in web.config
Suppose there is a key present in web config and which have the value 10.
Example:
<add key="Unit" value="10" />
You can modify the value programmatically using this code
Code Behind
Configuration webConfigApp = WebConfigurationManager.OpenWebConfiguration("~");
webConfigApp.AppSettings.Settings["Unit"].Value = "15";
webConfigApp.Save();
Namespace Required:
using System.Configuration;
using System.Web.Configuration;
Why Should we use that framework while we have facility to change it through writing code? Can you explain?
Thanks,
Abhay