更改 Web.config 连接字符串而不重置会话
如何
我想继续使用
我知道可以使用放置在单独文件中的自定义部分来避免会话重置,并在部分定义中添加restartOnExternalChanges = false。我知道
How can <connectionStrings> in Web.config be changed without resetting sessions of logged in users?
I'd like to keep using <connectionStrings> instead of creating a custom section because I use LINQ and I don't want to have to hack my DBML.
I know that session resets can be avoided using custom sections placed in a separate file with restartOnExternalChanges=false in the section definition. I know that <connectionStrings> can be put in a separate file but I cannot set restartOnExternalChanges=false because its section is defined in Machine.config and can't be overridden in Web.config (at least, I haven't figured out how to).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能。时期。
正如您所提到的,将配置设置外部化到单独的配置中可能会在大多数情况下有所帮助,因为在这种情况下,您不必修改总是导致应用程序重新启动的 web.config。
但正如您也提到的,在
的情况下,情况并非如此,据我所知,没有办法改变这种行为。您需要找到一种方法,用您可能需要的所有连接字符串预填充您的
部分(然后在任何给定时间选择“正确的”字符串),否则您将必须自己动手。马克
You cannot. Period.
As you mentioned, externalizing configuration settings into separate configs might help with most cases, since in that case, you wouldn't have to modify the web.config which always causes an app restart.
But as you also mention, in the case of
<connectionStrings>
, this is not the case, and as far as I know, there's no way to change that behavior.You need to find a way to either prepopulate your
<connectionStrings>
section with all the connection strings you might need (and then just pick the "right" one at any given time), or you'll have to resort to rolling your own.Marc