是否可以在不结束所有用户会话的情况下更改web.config?

Esp*_*spo 10 asp.net session web-config

是否可以更改web.config文件而不为网站上的所有用户提供新会话?

Bra*_*row 8

您可以将web.config的易失性部分移动到外部文件中,然后将IIS设置为在这些文件更改时不重新启动应用程序.

在下面的示例中,应用程序和连接字符串设置已移至web.config之外的另一个文件.

<?xml version="1.0"?>
<configuration>

  <appSettings configSource="appSettings.config"/>

  <connectionStrings configSource="connections.config"/>   

</configuration>
Run Code Online (Sandbox Code Playgroud)

完成后,您可以更改应用程序设置(或放在外部文件中的任何其他内容),而无需编辑web.config.

您也可以访问machine.config并使用restartOnExternalChanges属性,但应谨慎使用,因为它可能会产生意想不到的后果.某些部分(例如应用设置)已将此设置为"false".

<section name="appSettings" restartOnExternalChanges="false">
Run Code Online (Sandbox Code Playgroud)

有关此OdeToCode文章的更多详细信息,请参见此文章.