Modify Web.Config Programmatically?

  • Thread starter Stewart Armbrecht
  • Start date
S

Stewart Armbrecht

Does anyone know of a good example for modifying the web.config file
programmitically. I would like to update the web.config file's connection
string when I deploy the web application using a web set up project.
 
C

Chris Jackson

You can open up the web.config file as an XML file, and then parse and
modify it using whichever XML API suits your fancy. I haven't done enough
with web set up projects to advise you how to do this here.
 
Joined
Jun 11, 2009
Messages
9
Reaction score
0
update web.config programmatically

Since web.config file is xml file you can open web.config using xmldocument class. Get the node from that xml file that you want to update and then save xml file.

here is URL that explains in more detail how you can update web.config file programmatically.

http: patelshailesh.com/index.php/update-web-config-programmatically

Note: if you make any changes to web.config, ASP.NET detects that changes and it will reload your application(recycle application pool) and effect of that is data kept in Session, Application, and Cache will be lost (assuming session state is InProc and not using a state server or database).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top