Settings.settings file with settings for multiple regions

Discussion in 'ASP .Net' started by donet programmer, Nov 19, 2009.

  1. I thought of using Settings.settings feature that is new to .NET for
    storing connection strings info for TEST, INT and PROD regions.
    Currently we prefix the appSettings keys with TEST, INT and PROD in
    web.config (or app.config). For instance in my web.config I have
    following keys:

    <appSettings>
    <add key="TEST.Connection" value = "......" />
    <add key="INT.Connection" value = "......" />
    <add key="PROD.Connection" value = "......" />
    </appSettings>

    When we deploy application to each region we set the value of server
    variable ENVIRONMENT to "TEST", "INT" and "PROD".

    We then use following to get conn string :

    string connstring = [AppSettingsReader obj].GetValue( ENVIRONMENT +
    ".Connection")

    This gives us TEST connection string in TEST region, INT conn string
    in INT region etc.

    I would like to do something similar with Settings.settings file. Any
    ideas.
     
    donet programmer, Nov 19, 2009
    #1
    1. Advertising

  2. donet programmer <> wrote in news:e1d08968-9837-44b1-
    :

    > I thought of using Settings.settings feature that is new to .NET for
    > storing connection strings info for TEST, INT and PROD regions.
    > Currently we prefix the appSettings keys with TEST, INT and PROD in
    > web.config (or app.config). For instance in my web.config I have
    > following keys:
    >
    > <appSettings>
    > <add key="TEST.Connection" value = "......" />
    > <add key="INT.Connection" value = "......" />
    > <add key="PROD.Connection" value = "......" />
    > </appSettings>
    >
    > When we deploy application to each region we set the value of server
    > variable ENVIRONMENT to "TEST", "INT" and "PROD".
    >
    > We then use following to get conn string :
    >
    > string connstring = [AppSettingsReader obj].GetValue( ENVIRONMENT +
    > ".Connection")
    >
    > This gives us TEST connection string in TEST region, INT conn string
    > in INT region etc.


    You don't want to do this going forward, or at least it is not likely
    you want to continue this direction. In .NET 4.0 (release 1Q 2010),
    there are provisions for altering a config file on deploy, so there is
    no reason to consider this form of change for common config settings.

    As .NET 4.0 is Go Live now, you might consider looking at the impact up
    "upgrading" on your project and switching. No, I would not normally
    suggest going into a beta cycle, but your needs match what they are
    doing now. And the release is not that far away. And the Go Live means
    Microsoft has guaranteed an upgrade path for beta 2.

    Peace and Grace,
    Greg



    --
    Vote for Miranda's Christmas Story
    http://tinyurl.com/mirandabelieve

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Nov 19, 2009
    #2
    1. Advertising

  3. Thanks greg for the info. We currently use .NET 3.0 which we only
    recently switched to so no idea how long till we use .NET 4.0.

    I was able to resolve the issue and able to store multiple sets of
    values in my app.config file and still use intellisense to get its
    value. For those interested I am attaching the link below :

    http://blogs.msdn.com/johan_stenbergs_blog/archive/2005/11/11/491998.aspx

    Thanks
     
    donet programmer, Nov 19, 2009
    #3
  4. donet programmer <> wrote in news:e65c8ba0-77bb-463f-
    :

    > Thanks greg for the info. We currently use .NET 3.0 which we only
    > recently switched to so no idea how long till we use .NET 4.0.
    >
    > I was able to resolve the issue and able to store multiple sets of
    > values in my app.config file and still use intellisense to get its
    > value. For those interested I am attaching the link below :
    >
    > http://blogs.msdn.com/johan_stenbergs_blog/archive/2005/11/11/491998.aspx


    That is good info. If you get a chance, look at what .NET 4.0 is doing,
    however, and abstract in a similar manner. It will make it easy to switch.

    Peace and Grace,
    Greg

    --
    Vote for Miranda's Christmas Story
    http://tinyurl.com/mirandabelieve

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Nov 20, 2009
    #4
    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. Doug

    Hiding Regions - Alternatives

    Doug, Aug 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    339
    Dave Fancher
    Aug 3, 2004
  2. Bliss
    Replies:
    0
    Views:
    308
    Bliss
    Oct 26, 2004
  3. Humvee
    Replies:
    1
    Views:
    400
    Mr. Clean
    Jul 22, 2003
  4. Jerry Manner

    Click multiple regions on a map

    Jerry Manner, Jun 27, 2005, in forum: HTML
    Replies:
    3
    Views:
    432
  5. Daniel Pryde

    Regions of similarity in a matrix

    Daniel Pryde, Jan 7, 2004, in forum: Python
    Replies:
    0
    Views:
    305
    Daniel Pryde
    Jan 7, 2004
Loading...

Share This Page