Re: ConfigurationManager and web.config and ASP.NET refresh curiosity
- From: Brock Allen <ballen@xxxxxxxxxxxxxxxxx>
- Date: Mon, 04 Apr 2005 21:12:18 -0700
I was playing with the new ConfigurationManager class in the Feb CTP drop of VS 2005 and I noticed that if you make changes to the configuration inside of an ASP.NET page, those changes are immediately written to the web.config when you say Configuration.Save() but if I then try to access them, they do not appear to refresh within the request.
The reason is that the request is executing inside of an AppDomain that has cached the settings of the config file prior to the modification. You request makes changes which invalidates the cached config data. Upon the next request ASP.NET will launch a new AppDomain to load the new settings. So changes made won't be visible until the next request into the application.
Not completely unexpected I suppose but I was wondering if anyone knew if this is the way this is supposed to work or if the current request should have picked up the changes?
So, from above, no this is not to be expected. If your request were to see the changes immediaetly it would require creating the AppDomain and somehow passing the current request (mid-stream) over to the new AppDomain that has loaded the new settings. In short, it doesn't do this, so you won't see the changed settings.
Basically I added a new sqlCacheDependency using the configuration classes and then called the constructor of SqlCacheDependency with the corresponding information and it threw an exception because it couldn't find the setting I just wrote out to the web.config. I got around it by doing a response.redirect back to the page again and then executing the constructor which worked but if the changes won't take until a new page loads then I'd just like to know that is the case.
Voila! :)
-Brock DevelopMentor http://staff.develop.com/ballen
.
- References:
- ConfigurationManager and web.config and ASP.NET refresh curiosity
- From: Jay Hilyard
- ConfigurationManager and web.config and ASP.NET refresh curiosity
- Prev by Date: Re: Server cannot access application directory
- Next by Date: Re: Server cannot access application directory
- Previous by thread: ConfigurationManager and web.config and ASP.NET refresh curiosity
- Next by thread: Image align - how?
- Index(es):
Relevant Pages
|