Is there a way to write to web.config through code?

  • Thread starter Thread starter Christopher Ambler
  • Start date Start date
C

Christopher Ambler

That's pretty-much sums it up.

I've got an application that stores configuration values in the appSettings
area of the web.config, and I'd love to be able to make a page that allows
an authenticated user to make changes to those configuration options.
Everything seems to be read-only, though. I'd hate to use a database... that
would be overkill.

Thanks in advance!

Christopher
 
Every time web.config is modified the app restarts - so every time you wrote
to it, this would happen. That is probably one of the reasons there are no
built in methods to write to it.

However, you can load the file into an XML dom, change the settings manually
(without the convenient write methods you seem to be looking for), and then
save the XML back to the file.
 
Back
Top