
Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
I don't understand your response at all. Don't modify web.config at all?
Where do you suggest me to connection strings? Har coded in some .cs files?
It's a common practice to store connection strings into web.config then
change them for switching to defferent environments. But ASP.Net runtime
throws exceptions if connection strings are changed in my case.
>> I am getting the following exception every time I modified web.config,
>> the only way to fix it is to recycle application pool or restart IIS, but
[quoted text clipped - 6 lines]
> If you don't want your ASP.NET application to recycle, don't modify
> web.config... Store dynamic variables somewhere else...
Mark Rae [MVP] - 30 May 2008 04:46 GMT
[top-posting corrected]
>>> I am getting the following exception every time I modified web.config,
>>> the only way to fix it is to recycle application pool or restart IIS,
[quoted text clipped - 8 lines]
>
> I don't understand your response at all.
OK.
> Don't modify web.config at all?
Yes, that's right. DON'T MODIFY WEB.CONFIG AT ALL!
> Where do you suggest me to [store] connection strings?
In web.config - as many as you need.
> Hard coded in some .cs files?
Absolutely not.
> It's a common practice to store connection strings in web.config then
> change them for switching to different environments.
It most certainly isn't!!! Web.config is not designed for this sort of
behaviour, as you've discovered... Web.config is designed for storing
application-specific data and metadata WHICH NEVER CHANGES while the
application is running.
> But ASP.Net runtime throws exceptions if connection strings are changed in
> my case.
Yes, that's correct. Because web.config is not designed to be used in this
way...
Why do you need to modify your connection string(s) while your web
application is running?

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Juan T. Llibre - 30 May 2008 07:24 GMT
re:
!> I don't understand your response at all. Don't modify web.config at all?
He didn't say that at all.
He said "If you don't want your ASP.NET application to recycle, don't modify web.config".
If you modify web.config, your ASP.NET application *will* recycle.
re:
!> Where do you suggest me to connection strings?
!> Har coded in some .cs files?
No, but you could have a helper config file named connections.config, for example.
<connectionStrings configSource="connections.config"/>
To enable the configuration to be recognized on any change to "connections.config",
edit machine.config, in the <configSections> section, and edit <section name="connectionStrings" ... >,
adding : restartOnExternalChanges="true"
That'd make it :
<section name="connectionStrings" type="System.Configuration.AppSettingsSection, System.Configuration,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="true"
requirePermission="false" />
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
>I don't understand your response at all. Don't modify web.config at all? Where do you suggest me to connection
>strings? Har coded in some .cs files? It's a common practice to store connection strings into web.config then change
[quoted text clipped - 9 lines]
>> If you don't want your ASP.NET application to recycle, don't modify web.config... Store dynamic variables somewhere
>> else...