Anybody programming with ASP.NET knows that you can store custom application's settings in the web.config file, under the section, and programmatically read the values through the ConfigurationSettings class. When the application starts, the web.config is read and all its settings are cached, so that there isn't a IO operation every time a value is needed. The web.config file is also automatically monitored for changes, and when a change is detected the file is read and cached again, but more importantly, the application is restarted and all the pages in the same directory and the subdirectories are recompiled on the next request, because the new settings of the web.config file might affect the page's behavior (think about smart navigation, security, cookies and sessions, for example).
This means that if you frequently change the custom keys in the section, you'll cause frequent recompilation of the pages, and thus slow down the application. You can easily avoid this problem, at least for custom application settings, by storing the settings in an external file referenced from web.config. This option, undocumented but present also in ASP.NET 1.0, allows you to change your custom settings without editing the web.config file, and thus avoid the application restart. The drawback is that if you actually want to reload the settings, you have to manually force an application restart, for example by making a fake change to web.config.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.