ASP.Net 2.0 Configuration files.

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
 
J

Juan T. Llibre

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
============
 
A

Ashish

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 ?
 
J

Juan T. Llibre

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
============
 
S

Scott Allen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top