Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update ASP.NET web.config while still in process of client request

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

like image 375
user150528 Avatar asked Mar 18 '10 17:03

user150528


3 Answers

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).

like image 192
Jay Avatar answered Oct 19 '22 05:10

Jay


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

like image 24
John K Avatar answered Oct 19 '22 06:10

John K


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.

like image 25
Buggieboy Avatar answered Oct 19 '22 05:10

Buggieboy