How to edit and save connection string in web.config file during installation in C #?

  • I created an installer for a web application.
  • I want to change the default connectionstring in web.config with the connection string passed by the user from the installation.
+2


source to share


2 answers


The easy way might just be to read in the web.config file and replace the line and then output the web.config again:

e.g .: in web.config containing:

...
<add name="Application" connectionString="SETUP_CONNECTION_STRING" />
...

      



replace SETUP_CONNECTION_STRING

with the actual line:

This assumes its initial setup, where multiple parameters can be set without the need for configuration classes, etc.

+1


source


Can you help, take a look here Is it possible to change the configuration of ConnectionStrings at runtime?



NTN

0


source







All Articles