Partha
Partha

Reputation: 2192

How to edit and save the connectionstring in web.config file during the installation in c#?

Upvotes: 2

Views: 708

Answers (1)

Mark Redman
Mark Redman

Reputation: 24515

A simple way might be to simply Read in the web.config and do a string replace, then write out the web.config again:

eg: in web.config containing:

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

replace SETUP_CONNECTION_STRING with actual string:

This assumes its done on initial setup where multiple settings could be set without the need to use the Configuration classes etc.

Upvotes: 1

Related Questions