I am using ConfigurationManager.AppSettings collection to retreive configuration values from a Web.config file in an ASP.NET application. Does anyone know if values in AppSettings get cached in memory somehow or if a file read of Web.config occurs every time when retrieving a setting?
string someValue = ConfigurationManager.AppSettings["SomeSetting"];
Thanks
They are taken from memory, since the web.config is read only once when the application starts.
However, ASP.NET monitors the web.config file to detect and load changes
It is important to realize that the entire section is read, parsed, and cached the first time we retrieve a setting value. From that point forward, all requests for setting values come from an in-memory cache, so access is quite fast and doesn't incur any subsequent overhead for accessing the file or parsing the XML.
Application Configuration Files Explained in MSDN
For more info:
http://weblogs.asp.net/stevewellens/archive/2011/01/15/web-config-is-cached.aspx