Since the web.config file is an xml file, you can open web.config using the xmldocument class. Get the node from this xml file you want to update, and then save the xml file.
Here is a URL that explains in more detail how to programmatically update the web.config file.
http://patelshailesh.com/index.php/update-web-config-programmatically
Note: if you make any changes to web.config, ASP.NET will detect these changes and restart your application (pool of repeated application pools), and the effect of this will depend on the data stored in the session, application and cache (assuming that the session state is InProc and does not use a public server or database).
shailesh Feb 17 '10 at 20:11 2010-02-17 20:11
source share