ASP.Net 2.0 Configuration files.

Discussion in 'ASP .Net' started by Ashish, Dec 12, 2005.

  1. Ashish

    Ashish Guest

    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
     
    Ashish, Dec 12, 2005
    #1
    1. Advertising

  2. 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
    ============
    "Ashish" <> wrote in message news:O00ohA0$...
    > 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
     
    Juan T. Llibre, Dec 12, 2005
    #2
    1. Advertising

  3. Ashish

    Ashish Guest

    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 ?



    Juan T. Llibre wrote:
    > 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
    > ============
    > "Ashish" <> wrote in message news:O00ohA0$...
    >
    >>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

    >
    >
    >
     
    Ashish, Dec 12, 2005
    #3
  4. 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
    ============
    "Ashish" <> wrote in message news:eeDToq0$...
    > 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 ?
    >
    >
    >
    > Juan T. Llibre wrote:
    >> 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
    >> ============
    >> "Ashish" <> wrote in message news:O00ohA0$...
    >>
    >>>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

    >>
    >>
     
    Juan T. Llibre, Dec 12, 2005
    #4
  5. Ashish

    Scott Allen Guest

    On Mon, 12 Dec 2005 12:34:14 -0600, Ashish <>
    wrote:

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

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/
     
    Scott Allen, Dec 12, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Cade

    ASP.Net Configuration File

    Joel Cade, Jul 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    425
    David Berman
    Jun 22, 2004
  2. fred bliss
    Replies:
    3
    Views:
    2,933
    John Saunders
    Nov 13, 2003
  3. Steve Haun
    Replies:
    0
    Views:
    449
    Steve Haun
    Nov 16, 2003
  4. Mark
    Replies:
    0
    Views:
    831
  5. Stephan Koser
    Replies:
    3
    Views:
    675
    Juha Laiho
    Dec 7, 2004
Loading...

Share This Page