ASP.Net 2.0 Configuration files.

  • Thread starter Thread starter Ashish
  • Start date Start date
A

Ashish

Iam using a couple of external (other than web.config) configuration
files for my project , and i want their behavior to be like that of
web.config file ( the application should track changes and reload if
required),

is this possible in the new ASP.Net 2.0 ?

thanks
 
We have an answer to this from a MSFT authorized source.

---000---

One way to handle it is to use configuration file fragments and point
to them in your web config file. Your fragment would look like this,
without the namespace:

<connectionStrings>
<clear />
<add name="NorthwindSQL"
connectionString="Data Source=(local);Initial
Catalog=Northwind;Integrated Security=true;"
providerName="System.Data.SqlClient" />
</connectionStrings>

Your Web config would have this line, which uses the fragment:

<connectionStrings configSource="connections.config"/>

One significant advantage of using config file fragments for ASP.NET
apps is that config file fragments can be edited at runtime without
causing an application restart.

---000---

You can modify that example for different configuration sections.




Juan T. Llibre
ASP.NET MVP
============
 
Juan,

Thanks for the answer. I was wondering that if i change contents of the
"connections.config" file , would ASP.Net recognize it and reload the
application automatically ?
 
re:
Thanks for the answer. I was wondering that if i change contents of the "connections.config" file
, would ASP.Net recognize it and reload the application automatically ?

That's what this part of the answer explains :
One significant advantage of using config file fragments for ASP.NET
apps is that config file fragments can be edited at runtime without
causing an application restart.

You don't need to reload the application.

ASP.NET will recognize runtime changes to
config file fragments without needing an application reload/restart.



Juan T. Llibre
ASP.NET MVP
============
 
I was wondering that if i change contents of the
"connections.config" file , would ASP.Net recognize it and reload the
application automatically ?

You should be able to do this with the restartOnExternalChanges
property for the configuration section. If you look in web.config,
appSettings will not restart for external changes, but
connectionStrings will. You could always moidfy these default
settings, of course.
 
Back
Top