I created an HTTPModule that should log reauests and responses.
The parameters that tells the http module how to work located in the web.config. But, in order to let the http module work with the latest values of the parameters, each request I r开发者_开发问答ead the parameters from the app.config.Is there a way I can detect changes in the web.config so I can reload the http module parameters instead of reading them each time there is a response?
You don't need to do that at all. You can load these properties only once and store them somewhere. Each time the web.config changes whole your ASP.NET application restarts and http module will have to initialize again.
@Ladislav & @velijoz are correct. The web.config is read once and the values stored in memory until the app restarts, because the web.config was changed for example.
Unless of course you're opening and reading the file directly. That would be a bad thing.
If the settings change regularly, you could put them in another file, read the values and store them in the cache with a cache dependency on the file. That way you could change the settings without restarting your app everytime. when you change the settings file, the cache dependency would invalidate the cache and your code could read the file again.
Simon
what I have recently learnt is that when for example you change your web.config technically the asp.net application does not restart - it unloads. When you fire in the next request or start the app pool it then begins to load.
I'm filing this under a common misconception of asp.net developers ;)
精彩评论