views:

265

answers:

1

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

+4  A: 

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

marc_s