473,473 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

get/set data web.config

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


Jun 27 '08 #1
7 1420
"John Devlon" <Jo********@hotmail.comwrote in message
news:qa******************@newsfe05.ams2...
Does anyone have the correct syntax to get and set the system settings in
the web.config file ?
http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
I would like to read and change the smtp server, login, password and from
adress....
Be aware that any changes to web.config while the web app is running will
cause it to recycle, thereby tearing down all currently active sessions...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
Thanx Mark,

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

John

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:eM**************@TK2MSFTNGP02.phx.gbl...
"John Devlon" <Jo********@hotmail.comwrote in message
news:qa******************@newsfe05.ams2...
>Does anyone have the correct syntax to get and set the system settings in
the web.config file ?

http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>I would like to read and change the smtp server, login, password and from
adress....

Be aware that any changes to web.config while the web app is running will
cause it to recycle, thereby tearing down all currently active sessions...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #3
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.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"John Devlon" <Jo********@hotmail.comwrote in message
news:mv*******************@newsfe18.ams2...
Thanx Mark,

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

John

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:eM**************@TK2MSFTNGP02.phx.gbl...
>"John Devlon" <Jo********@hotmail.comwrote in message
news:qa******************@newsfe05.ams2...
>>Does anyone have the correct syntax to get and set the system settings
in
the web.config file ?

http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>>I would like to read and change the smtp server, login, password and
from adress....

Be aware that any changes to web.config while the web app is running will
cause it to recycle, thereby tearing down all currently active
sessions...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Jun 27 '08 #4
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
>

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:eM**************@TK2MSFTNGP02.phx.gbl...
>"John Devlon" <Jo********@hotmail.comwrote in message
news:qa******************@newsfe05.ams2...
>>Does anyone have the correct syntax to get and set the system settings in
the web.config file ?

http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>>I would like to read and change the smtp server, login, password and from
adress....

Be aware that any changes to web.config while the web app is running will
cause it to recycle, thereby tearing down all currently active sessions...
-- Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #5

Mark,

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

Thanx

John

>
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:eM**************@TK2MSFTNGP02.phx.gbl...
>"John Devlon" <Jo********@hotmail.comwrote in message
news:qa******************@newsfe05.ams2...
>>Does anyone have the correct syntax to get and set the system settings
in
the web.config file ?

http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>>I would like to read and change the smtp server, login, password and
from adress....

Be aware that any changes to web.config while the web app is running will
cause it to recycle, thereby tearing down all currently active
sessions...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Jun 27 '08 #6

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/tutorials...-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" <Jo********@hotmail.comwrote in message
news:mv*******************@newsfe18.ams2...
Thanx Mark,

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

John

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:eM**************@TK2MSFTNGP02.phx.gbl...
>"John Devlon" <Jo********@hotmail.comwrote in message
news:qa******************@newsfe05.ams2...
>>Does anyone have the correct syntax to get and set the system settings
in
the web.config file ?

http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>>I would like to read and change the smtp server, login, password and
from adress....

Be aware that any changes to web.config while the web app is running will
cause it to recycle, thereby tearing down all currently active
sessions...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Jun 27 '08 #7
"John Devlon" <Jo********@hotmail.comwrote in message
news:hX******************@newsfe15.ams2...
>>Does anyone have the correct syntax to get and set the system settings
in
the web.config file ?

http://msdn2.microsoft.com/en-us/lib...onmanager.aspx
>>I would like to read and change the smtp server, login, password and
from adress....

Be aware that any changes to web.config while the web app is running will
cause it to recycle, thereby tearing down all currently active
sessions...

Do you think reading and writing to a resource file using a shared class
is a good solution ?
It largely depends what you're trying to do and why you're trying to do
it...

If the values that you want to read out of web.config are unlikely to change
very often, I'd probably read them into Application variables at
Application_Start and then refer to them from there thereafter...

However, if they are likely to change quite often, then web.config probably
isn't the best place to start from anyway...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mairead O' Donovan | last post by:
From: davidkeaveny@gmail.com (CtrlAltDel) Newsgroups: microsoft.public.dotnet.datatools Subject: Unit-testing applications that use the Microsoft.Patterns.EnterpriseLibrary.Data Date: 15 Apr 2005...
0
by: Michael Probst | last post by:
Hi all, I am new to .NET and the way XML data is handled in .NET I wrote a small application with .NET forms in C++ The application reads data from an XML file to fill-in the fields of the...
5
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: ...
5
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1....
2
by: js | last post by:
I got this error when I moved my application to a new Windows 2003 server. I installed and recompiled the 'Microsoft.Practices.EnterpriseLibrary - June 2005" then added these assemblies to the...
2
by: malice | last post by:
I have been searching the internet for 12+ hours on how to do this. At this point I'm about to give up. I am using VB .Net 2.0 with the enterprise library jan 2006 release. This is my first time...
9
by: KarlM | last post by:
After reading some articles regarding confuguration data I'm a bit confused. Where is the right place for storing configuration data? - XML-files? - registry? - INI-files? (from a users point...
1
by: Jon | last post by:
Hello all - just a spot of advice required. I'm wanting to write a number of data layers that will be used to carry out the typical CRUD operations against a database - so 1 database will be...
6
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
I have configuration data for a web application stored in a file galleryserverpro.config located in a config folder off the root application. Web.config references this file like this:...
5
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a app that uses several membership/role providers. I can list these Providers with the code: Dim rootWebConfig1 As Configuration rootWebConfig1 =...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.