Sunday, October 19, 2008

Modify Web Configuration file without restarting asp net worker process (aspnet_wp).

Modify Web Configuration file without restarting asp net worker process (aspnet_wp).

No one in the world can say that web.config file will remain intact after the deployment. Modifications have to happen to some or the other parameters of the web configuration file like one has to add or remove key value pairs from appsettings section etc…

So what?
As soon as the webs configuration file is saved the aspnet_wp worker process of that particular web application gets restarted and all the current sessions and data are lost.

This can cause tremendous issues to an organization whose application needs to be up for 24*7.

To recover from such kind of scenario Microsoft has already provided a great tweak to handle this.

Following are some steps that need to be followed.
Step 1) Make a separate configuration file lets say for example appsettings.config with the following xml data.

[sourcecode language='html']



 
 
 


[/sourcecode]

Step 2) Now in the original web.config file make your appSettings section look like below

[sourcecode language='html']




[/sourcecode]

You are done.

 
Place a debug point on the Application_Start event in global.asax file and check that changing appsettings.config does not restart the worker process.