Tutorial :Is IIsreset always neccessary when storing my Web.Config appsettings in a separate file?


I've got an ASP.Net app in which my AppSettings node from the Web.Config xml is stored in a separate file.

So my Web.Config contains this:

<appSettings file="AppSettings.config" />  

Whenever I change a setting in there I have to do an iisreset to force the changes to kick in. In other words, my changes in this file aren't detected the same way changes to the Web.Config is.

Does anyone know how I can make these changes take effect automatically, like it does with the Web.Config?



Edit: In response to other answers. You can change the machine.config to include the restartOnExternalChanges="true" option for appSettings; however, this will cause ALL of your web applications to restart when you touch any of the external app settings files. (Also, I think this may only work when you use configSource="file.name" not file="file.name".)

This is by design and the only way to cause the application to reset is manually or via a script.

You can take a look here for a script which will reset your application without restarting iis:



Open web.config in notepad. Save it. Exit notepad.


How are you accessing your app settings in code? I have an external appsettings file (though i use the configSource property instead of file) and any changes I make are immediately available when using ConfigurationManager.AppSettings("settingname") in code to get the value.

With that said, if you really do need an app restart for some other reason, and you have access to the machine.config file on the server, in the definition for the appSettings section, there is an attribute named RestartOnExternalChanges that can be set to true (defaults to false) and then the appSettings section will behave like you want it to, I believe.


I know this is an old thread, but something to add.

If you use:

<appSettings file="AppSettings.config" />  

Then changes to the external file will not be available until a change to web.config is made or a restart is performed.

But if you change that to:

<appSettings configSource="AppSettings.config" />  

The changes to those settings are available in your code immediately without a restart or a web.config change.

I just verified that this is the case with a repeatable test.


You can write a filewatcher service to monitor your custom config file. Issue iisrest command when the changed event gets executed inside the service.


If you were to instead use ConfigurationRedirection (introduced with IIS 7), you could configure IIS to poll for changes to your external configuration file (starting with IIS 7.5). This would cover the whole .config file, though, not just the appSettings section.

This allows you to store configuration settings on a UNC server that all Web server computers in the Web farm can access.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »