11

Could you tell me what exactly happens when we edit the Web.config (at runtime) on a IIS server.

Is the application that depend of the web.config automatically restarted? If yes is it possible to cancel the automatic restart (or reload of the web.config)?

1
  • You could try turning on file access auditing to see whether or not IIS reads the web.config after you modify it.
    – Eric H
    Nov 1, 2009 at 12:10

4 Answers 4

10

The ASP.NET AppDomain is restarted whenever you 'touch' web.config. It's possible to turn off the File Change Notification (FCN) for a folder, but it's usually not the best bet if you can help it. If you do turn it off, it just means that you need to manually recycle the app pool for changes to take effect.

Prior to IIS7, only ASP.NET changes would cause the AppDomain recycle, but with IIS7 and many of the settings living in web.config, this is a more common issue. i.e. changing a default doc in IIS 7 Manager will cause that AppDomain recycle now.

Ideally you just need to keep your change rate down, or sometimes apply the change to applicationHost.config (which doesn't cause the AppDomain recycle) rather than web.config.

4

The application that uses the web.config will restart when you change it, there's more info here:

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

I don't know of any way to prevent this from happening (and I'm not sure why you'd want to - perhaps you can provide some more details of what you're trying to achieve).

3

FYI - In ASP.NET 2.0 you can use the built in Health Monitoring Events to log application restarts along with the reason for the restart. This will enable you to clearly document when and how often it occurs. This is accomplished by editing the master web.config for the machine.

For more information:

http://blogs.msdn.com/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspx

3

[JUST A NOTE]

I know this is an old one but this still deserves to noted.

Scott Forsyth - MVP answer is incorrect.

The ASP.NET AppDomain is restarted whenever you 'touch' web.config.

This is wrong.


Whisk answer is the most technically correct & complete answer as it includes a link to the MSDN that includes one important detail:

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.

This is particular important when we are talking web services. This indicates that it may be ok do a mid-day restart safely.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .