Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nigel Wilson 945 posts 2077 karma points
    Feb 29, 2012 @ 22:35
    Nigel Wilson
    0

    External appsettings / web.config

    Hi there

    Just seeking some feedback.

    I am at the start of a project whereby I am looking to create a prepackaged website solution within Umbraco.

    The prepackaged solution will contain a range of configuration settings and I would prefer to keep these outside of the web.config file.

    I have just read that you can add a "file" attribute to appSettings - so as a test I tried the following:

    <appSettings file="~/config/mycustomconfig.config">

    ...
    </appSettings>

    I removed the umbracoDbDsn key from web.config and placed in "mycustomconfig.config" as follows:

    <?xml version="1.0" encoding="utf-8" ?>
    <appSettings>
      <add key="umbracoDbDSN" value="..." />
    </appSettings>

    This however failed - the database connection couldn't be read.

    In terms of the database I am happy to keep it in the web.config - it was just a simple test to see if/how this might work.

    However for other application settings will this work within an Umbraco environment ?

    I am in the early stages and so have not yet put together a test user control to try and output a custom setting - this is a logical next step, however thought some constructive feedback from "those who are smarter than me" might assist me in heading down a better path.

    Cheers

    Nigel

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 29, 2012 @ 22:45
    Tom Fulton
    0

    Hi Nigel,

    I haven't tried this but you might try using <appSettings configSource="config\mycustomconfig.config" />, then duplicating the <appSettings> section there.

    This is how I achieve it in the Structure Extensions package and it works like a treat:  <StructureExtensions configSource="config\StructureExtensions.config" />

    More info from google:  Using configSource to split configuration files

    HTH,
    Tom

  • Nigel Wilson 945 posts 2077 karma points
    Feb 29, 2012 @ 23:09
    Nigel Wilson
    1

    Hi Tom

    Thanks for the lightning fast response - appreciate the input.

    Unfortunately "configSource" doesn't seem to work..

    I have got it to work using the following:

    <appSettingsfile="config\mycustomconfig.config">
    ...
    </appSettings>

    And then naturally the following worked fine.

    testoutput.Text = System.Configuration.ConfigurationManager.AppSettings["nigelTest"].ToString()

    So maybe I should have tried this first before posting, but maybe someone will stumble across this and it will help out when figuring out the best way to record some config settings. I know I could have used this knowledge 2 years ago on a site.

    Cheers

    Nigel

Please Sign in or register to post replies

Write your reply to:

Draft