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.
5 comments:
Great article!!, i will do this next monday in my work.
Thanks
Unfortunately this doesn't work. The new setting you are going to put in the newly creates appsettings file won't take affect untill you restart the appdomain so yu are avoiding the automatic restart of the application but you losing the ability to have the new settings activates at same time so we are back to where we started.
Thats not correct. In the example depicted just go and place a button clicking on which it will fetch your data and write it to a page or lable just to check the value. Now start of with the application. Go and change the value in the external appsettings file and just click the button and you will get your answer.
Hi, Dhaval,
Just wanted to know, will it happen in IIS7 (or VS2010)? I tried placing a breakpoint in Application_Start event, ran the application. then change web.config to add new key and hit save but that didn't bring me to my breakpoint in Application_start event.
It should. Try to refresh your page after you save.
Post a Comment