开发者

Change Web.config connectionStrings without resetting sessions

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).


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜