get/set data web.config

J

John Devlon

Hi

Does anyone have the correct syntax to get and set the system settings in
the web.config file ?

I would like to read and change the smtp server, login, password and from
adress....

thanx

John
 
J

John Devlon

Thanx Mark,

I didn't know that.... Better to store the data somewhere else then....

John
 
H

Hans Kesting

John Devlon brought next idea :
Thanx Mark,

I didn't know that.... Better to store the data somewhere else then....

John

The values you mention seem pretty static, so a one-time configuration
at install is all that is needed. In that case web.config is fine.
Values that have to be changed frequently are best kept elsewhere (some
custom config file, database)

Hans Kesting
 
C

Cowboy \(Gregory A. Beamer\)

Very much so.

In addition, it can be impossible to update web.config from your app
(definitely in 1.x), as the app locks the file. Unless you are truly working
with configuration elements, I would store in an XML file or a database.

In .NET 2.0, you can specify additional configs, that you can alter while
the site is running, if these truly are "dynamic" config elements, but I
would consider metadata tables in a database first.


John Devlon said:
Thanx Mark,

I didn't know that.... Better to store the data somewhere else then....

John
 
J

John Devlon

Mark,

Do you think reading and writing to a resource file using a shared class is
a good solution ?

Thanx

John

 
S

sloan

You can try this trick:


<?xml version = "1.0" encoding = "utf-8" ?>

<configuration>

<appSettings file="CustomAppSettings.config" >

</appSettings>

</configuration>



Contents of CustomAppSettings.config

--start, do not include this line
<appSettings>

<add key="demokey1" value="demovalue1" />

</appSettings>

--end, do not include this line


And this is Peter's great writeup about it.


http://www.eggheadcafe.com/tutorial...180-c1f564b41f85/some-aspnet-20-configur.aspx


I don't think the webapp is recycled with this method. I haven't
specifically tested it.

...

Don't forget to add POST BUILD events if you doing non asp.net stuff
(winforms, console apps, etc).
(this comment for future readers more than you, since you're doing asp.net)







John Devlon said:
Thanx Mark,

I didn't know that.... Better to store the data somewhere else then....

John
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top