6

Just to be safe, when I make changes in the values of the appSettings in the Web.config I always restart the WebSite so all the changes can be refreshed. But do I really need to restart it? how is IIS handling the appSetting values, is it reading the values in one time (once you start the application) or is IIS reading it every time a client is accessing the website?

Romeo
  • 1,791
  • 8
  • 25
  • 41

1 Answers1

6

Actually, it is not the "Website" but the "App Pool" that needs the restart. Remember the website pipeline in IIS has no "executable" code, just markup.

This is however treated as a "Per App Pool" setting by IIS. In your INETMGR, open the properties of any app pool and look for this setting: "Disable Recycling for Configuration Changes" (under the Recycling group of settings). If you set this to "True", then IIS will not monitor for config changes FOR THAT APP POOL's CONFIG FILES and will not restart the app pools if you edit/change something. However, that means you must manually recycle --- a valid scenario if you are updating the website and want to change the BIN folder and multiple .config files in the hierarchy. Left on its own, in the minimum condition of one web.config file, that's two app pool restarts.. one for the BIN changes and one for web.config.

  • good answer @Sujay, So this means that I dont need to restart my website every time I a change a value in my appconfig. one more question though. does IIS read these values at one time and store it in the memory or does it read the values every time a client is accessing the website? – Romeo May 11 '14 at 07:01
  • @rcadaoas : based on tbe behavior I have seen, it has as a watcher implementation and performs a reload when the files change. It also "appears" to have a checksum kind of monitoring because sometimes I see that if you replace the same file (re-copy the same DLL in the BIN folder) the recycle does not appear to happen. –  May 11 '14 at 07:04
  • @SujaySarma: one question. In a super delicate production environment, could changing the value of an appsetting entry cause problem server side? I mean, not exceptions related to value, recycling APP pool is something dangerous for transactions or the server may not restart? – Revious Nov 28 '14 at 10:54
  • 1
    @Revious, app pool restarts will cause a delay of at least a few seconds for all new requests. – James Nov 28 '14 at 10:58
  • @Sujay, just to clarify, IIS can't tell when you're 'done' making changes. It could restart many, many times if you have a lot of bin files you are copying (like if you are using precompiling). File deletes elsewhere in the site will also cause restarts. – James Nov 28 '14 at 11:03
  • Perfectly valid @James. my reply was limited to the question about whether they need to do an IISRESET in addition to updating the files (and I said no, IIS would be doing that for you anyway). –  Nov 28 '14 at 11:05
  • I get instead a weird effect.. when I edit the web.config (even only adding a single space) I got an error like this: Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. – Revious Nov 28 '14 at 11:46
  • Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off". – Revious Nov 28 '14 at 11:49