How to write value to web.config

M

Mark Rae

I can use code to read the value, but how can I write the value back to
web.config after I change it?

Generally, you wouldn't (need to) do this - web.config is typically used to
store static variables which never, ever change across all instances of your
web app... Typical examples might include the connection string to your
backend database, the address of your SMTP server, etc...

IMO, if you find yourself needing to change any of the settings in
web.config, you probably shouldn't be storing them there in the first
place...

Why do you need to change this value?
 
K

Kevin Spencer

This is only true in the .Net Framework 1.1. He mentioned using VS.Net 2005,
which means he's developing on the .Net 2.0 platform, where there are
configuration sections you can modify and save.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
M

Mark Rae

This is only true in the .Net Framework 1.1. He mentioned using VS.Net
2005, which means he's developing on the .Net 2.0 platform, where there
are configuration sections you can modify and save.

Indeed - I didn't say it couldn't be done, only that IMO it wasn't a good
idea.
 
A

ad

I do according the article.
But it fail in run time at line:
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
The error message is
exePath must be specified when not running inside a stand alone exe.

How can I do?
 

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,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top