get/set data web.config
am 18.04.2008 16:24:20 von 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
Re: get/set data web.config
am 18.04.2008 16:33:15 von mark
"John Devlon" wrote in message
news:qa2Oj.17652$_h7.2374@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/library/system.configuratio n.configurationmanager.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
Re: get/set data web.config
am 18.04.2008 16:46:40 von John Devlon
Thanx Mark,
I didn't know that.... Better to store the data somewhere else then....
John
"Mark Rae [MVP]" schreef in bericht
news:eMaEjEWoIHA.5016@TK2MSFTNGP02.phx.gbl...
> "John Devlon" wrote in message
> news:qa2Oj.17652$_h7.2374@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/library/system.configuratio n.configurationmanager.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
Re: get/set data web.config
am 18.04.2008 17:11:27 von 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
>
>
> "Mark Rae [MVP]" schreef in bericht
> news:eMaEjEWoIHA.5016@TK2MSFTNGP02.phx.gbl...
>> "John Devlon" wrote in message
>> news:qa2Oj.17652$_h7.2374@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/library/system.configuratio n.configurationmanager.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
Re: get/set data web.config
am 18.04.2008 17:11:46 von NoSpamMgbworld
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" wrote in message
news:mv2Oj.56832$Lq5.25405@newsfe18.ams2...
> Thanx Mark,
>
> I didn't know that.... Better to store the data somewhere else then....
>
> John
>
>
>
> "Mark Rae [MVP]" schreef in bericht
> news:eMaEjEWoIHA.5016@TK2MSFTNGP02.phx.gbl...
>> "John Devlon" wrote in message
>> news:qa2Oj.17652$_h7.2374@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/library/system.configuratio n.configurationmanager.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
>
>
Re: get/set data web.config
am 18.04.2008 17:16:26 von John Devlon
Mark,
Do you think reading and writing to a resource file using a shared class is
a good solution ?
Thanx
John
>
> "Mark Rae [MVP]" schreef in bericht
> news:eMaEjEWoIHA.5016@TK2MSFTNGP02.phx.gbl...
>> "John Devlon" wrote in message
>> news:qa2Oj.17652$_h7.2374@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/library/system.configuratio n.configurationmanager.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
>
>
Re: get/set data web.config
am 18.04.2008 17:18:53 von sloan
You can try this trick:
Contents of CustomAppSettings.config
--start, do not include this line
--end, do not include this line
And this is Peter's great writeup about it.
http://www.eggheadcafe.com/tutorials/aspnet/e54f2d32-72c4-4d 2b-b180-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" wrote in message
news:mv2Oj.56832$Lq5.25405@newsfe18.ams2...
> Thanx Mark,
>
> I didn't know that.... Better to store the data somewhere else then....
>
> John
>
>
>
> "Mark Rae [MVP]" schreef in bericht
> news:eMaEjEWoIHA.5016@TK2MSFTNGP02.phx.gbl...
>> "John Devlon" wrote in message
>> news:qa2Oj.17652$_h7.2374@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/library/system.configuratio n.configurationmanager.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
>
>
Re: get/set data web.config
am 18.04.2008 17:35:05 von mark
"John Devlon" wrote in message
news:hX2Oj.76656$5o5.5808@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/library/system.configuratio n.configurationmanager.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