Re: ConfigurationManager and web.config and ASP.NET refresh curiosity

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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



.



Relevant Pages

  • Re: Iphone bloccato
    ... terminal settings. ... The original activation state is Unactivated ... Configuration: iPod USB Interface ... request 4:, keys ...
    (it.comp.macintosh)
  • ANN: ISMRR: Request & Response - Update Notice - 1.0.1.47
    ... Request & Response Tracking that offers several new features as well as ... -Added option in SQL Repository to save to Login SQL in User Settings ... -Added Grid Font to Settings ... -Fixed problem with locations not resetting on reports on server change ...
    (borland.public.delphi.thirdpartytools.general)
  • RE: Publish to External FrontPage Server
    ... meaning Auto config, use proxy I am able to connect to the remote website. ... How can I make this work without having to disable the IE settings everytime ... Publish to External FrontPage Server ...
    (microsoft.public.isa)
  • Re: [kde] Hangover from kde 3.5 in kde4 when launching file manager after plugging in a SSC card
    ... generically aka system settings", settings (got that, the kcontrol aka ... User Settings", "File Associations". ... the mimetype is determined automatically (by file ... it's very likely a system config ...
    (KDE)
  • Re: Justified moaning?, I like to think so.
    ... I might have guessed you were going to ask for the steps to reproduce ... caching the settings for the current project and then either: ... Erroneously combining the new config with what's cached in some way ... new projects default to either Debug or Release and are those default ...
    (borland.public.delphi.non-technical)