views:

135

answers:

4

What happen if web.config gets updated while ASP (ASP.NET 2.0) server still process client request? - Will the process be killed? - If not, will the process read the updates in web.config.

thanks for any input

+2  A: 

Microsoft: "ASP.NET will serve all pending requests before restart"

-- http://msdn.microsoft.com/en-us/library/ms178473.aspx

When an application restart is required, ASP.NET will serve all pending requests from the existing application domain and the old assemblies before restarting the application domain and loading the new assemblies.

and following the flow of logic through changes to the asp.net Web.config file ...


"Configuration Changes Cause a Restart of the Application Domain"

The app effectively restarts. However there is also a trick noted in this first blurb to work around that "issue".

Changes to configuration settings in Web.config files indirectly cause the application domain to restart. This behavior occurs by design. You can optionally use the configSource attribute to reference external configuration files that do not cause a restart when a change is made. For more information, see configSource in General Attributes Inherited by Section Elements.

Attempts to change a configuration file by someone who does not have permission to edit the file will not cause a restart of the application domain.

^-- http://msdn.microsoft.com/en-us/library/ackhksh7.aspx

Loss of State

Your application, session and other states will be lost if stored in process ...

When using the in-process session-state mode, session-state data is lost if aspnet_wp.exe or the application domain restarts.

^-- http://msdn.microsoft.com/en-us/library/87069683(VS.71).aspx

The life-cycle implications of information stored in application state. The .NET Framework application domain or the process hosting a .NET-based application can be torn down and destroyed at any moment during application execution (as a result of crashes, code updates, scheduled process restarts, and so on).

^-- http://msdn.microsoft.com/en-us/library/bf9xhdz4(VS.71).aspx


Etc... Just some miscellanei. Info about storing session state out of process.

^-- http://msdn.microsoft.com/en-us/library/ms178586.aspx

John K
Definitely very true and good citations, I responded to a poster asking how to make a button to restart their web app and told them they want it to just update the web.config and got DVs for it!
Chris Marisic
I prefer protecting web.config from writes and telling user to instead write/kick the external config file 'external.config' linked into Web.config as: <section name="mine" type="y" restartOnExternalChanges="true" />|and| <mine configSource="myexternal.config"></mine>
John K
+2  A: 

I believe that if you make any changes to web.config, ASP.NET automatically reloads your application by recycling the application pool. This of course will result in Session, Application, and Cache data of an InProc session state being lost.

Buggieboy
Note that you can see this by simply making some trivial modification to the web.config in your text editor while your app is running and then saving it back to disk.
Buggieboy
A: 

The AppDomain will be unloaded after the request finishes.

SLaks
So the request will still be processed, and response will be sent back to client correct until next request, is that right?
@user: I believe so.
SLaks
+3  A: 

The new web.config is effectively a copy, so an ongoing request will finish unaffected -- it will not pick up the changes. When the request is complete, the new web.config will be written over the old one and subsequent requests will work from the updated values (in a new application domain).

Jay