I have the following line of code called very often:
var configValue = System.Configuration.ConfigurationManager.AppSettings["ConfigValueKey"];
Do I take a disk hit for ASP.Net to retrieve the item from the web.config, or is it smart enough to cache the value in memory and only refresh the cache when the web.config changes?
The configuration data is kept in memory. However, ASP.NET will watch for changes in web.config and recycle the application domain if the file is changed.
Among other things all the user sessions will be lost, that’s why it is not a good thing to touch the web.config while the application is running.