Since this is the web application you want to change, I would go with the WebConfigurationManager.
If the configuration value that you are going to change is in a separate section, you need to get this section first:
var myConfiguration = (Configuration)WebConfigurationManager.OpenWebConfiguration("~");
var section = (MySectionTypeHere)myConfiguration.GetSection("system.web/mySectionName");
myConfiguration.Save();
Keep in mind that the web application will be restarted each time web.config changes.
A more detailed article explaining this is available here .