Espo Espo - 6 months ago 24
ASP.NET (C#) Question

Is it possible to change web.config without ending all user sessions?

Is it possible to change the web.config file without giving all the users on the site a new session?


You can move the volatile portions of the web.config into external files and then set up IIS to not restart applications when those files change.

In the example below, application and connection-string settings have been moved to another file, outside of the web.config.

<?xml version="1.0"?>

  <appSettings configSource="appSettings.config"/>

  <connectionStrings configSource="connections.config"/>   


Once that's done, you can make changes to app settings (or whatever else you put in the external file) without editing the web.config.

You can also visit the machine.config and play with the restartOnExternalChanges attribute, but this should be used with caution as it could have unintended consequences. Some sections, such as app-settings, already have this set to "false".

<section name="appSettings" restartOnExternalChanges="false">

More details are available in this OdeToCode article.