HighTechTalks DotNet Forums  

How does ConfigurationManager.AppSettings.Set stores values?

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss How does ConfigurationManager.AppSettings.Set stores values? in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
natasha
 
Posts: n/a

Default How does ConfigurationManager.AppSettings.Set stores values? - 03-05-2006 , 04:14 PM






Hello everybody,
you can use ConfigurationManager.AppSettings.Set method
(ConfigurationManager is in System.Web.Configuration namespace) to store a
modified value from web.config.
To be practical, you define a custom key in web.config:

<appSettings>
<add key="ReportButtonClick" value="0" />
</appSettings>

retrieve value of the key with Get method:

counter = ConfigurationManager.AppSettings.Get("ReportButton Click")

modify this value:

counter = counter + 1

and write it back with Set method:

ConfigurationManager.AppSettings.Set("ReportButton Click", counter)

If I access back value with Get method, I find modified value but, of
course, web.config is NOT modified.
Where does Set method stores property's value?

Reply With Quote
  #2  
Old   
Alvin Bruney - ASP.NET MVP
 
Posts: n/a

Default Re: How does ConfigurationManager.AppSettings.Set stores values? - 03-06-2006 , 01:25 PM






it's an in-memory story. If you need it to actually modify the value inside
the config file, use one of the xml file objects to add the appropriate
value to the config. This is not a recommended approach by the way, but it
is a valid one.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



"natasha" <natasha (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hello everybody,
you can use ConfigurationManager.AppSettings.Set method
(ConfigurationManager is in System.Web.Configuration namespace) to store a
modified value from web.config.
To be practical, you define a custom key in web.config:

appSettings
add key="ReportButtonClick" value="0" /
/appSettings

retrieve value of the key with Get method:

counter =
ConfigurationManager.AppSettings.Get("ReportButton Click")

modify this value:

counter = counter + 1

and write it back with Set method:

ConfigurationManager.AppSettings.Set("ReportButton Click", counter)

If I access back value with Get method, I find modified value but, of
course, web.config is NOT modified.
Where does Set method stores property's value?



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.