Copied to clipboard

Flag this post as spam?

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


  • Martin Skov Nielsen 22 posts 47 karma points
    Mar 23, 2013 @ 21:30
    Martin Skov Nielsen
    0

    Adding additional config files

    Hi guys!

    I'm developing a package and need some config settings. IF it is possible I'd like to avoid changing the web.config. There're several *.config files in the config folder. Is it possible to add your own config files there and have Umbraco load it?

  • Martin Skov Nielsen 22 posts 47 karma points
    Mar 23, 2013 @ 21:56
    Martin Skov Nielsen
    0

    Ok - I've found most of what I was looking for here: http://our.umbraco.org/wiki/reference/packaging/package-actions/community-made-package-actions

    It doesn't allow me to load my own config, but it seems there's a safe way to update the web.config, so for me at this point that is sufficient.

    I'd still like to know how I could do it the other way though...

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 25, 2013 @ 23:15
    Jan Skovgaard
    0

    Hi Martin

    I will at any time recommend ang beg you to do a custom config that can be placed in the config folder. The more it can be abstracted from the web.config the better in my opionion It makes it much easier to get an overview and know where to have a look at things.

    Btw it would be great if you would attach a forum to the project here on our so all the knowledge about bugs etc. is kept central in one place rather than external.

    I had a short look at your package yesterday and it looks interesting but I could not get the thing working since I don't know what exactly to add to the web.config. In the description it says I should add my API key...but it does not say how :) - I'm probably not the only one having that issue.

    Looking forward to see how your package progress.

    /Jan

  • Martin Skov Nielsen 22 posts 47 karma points
    Mar 26, 2013 @ 07:31
    Martin Skov Nielsen
    0

    Hi Jan

    First of all thank you for taking the time to try out my package. I strongly agree that the web.config should be change at little as possible for many reasons.

    BUT! If I simply put in my own config file in the /config folder my setting (yes there's only one) is not loaded/available? So how do I load or access it?

    -----

    The way to enter the value for the setting would be to open the web.config file (another reason not to add custom settings here) and paste in as the value for the key that is added during installation (msSecKey).

    Now in my mind the ideal way would be to allow users to enter their secret key during installation or at least once it's done, but I currently don't know how to achieve this...

    //Martin

  • Martin Skov Nielsen 22 posts 47 karma points
    Apr 04, 2013 @ 16:43
    Martin Skov Nielsen
    1

    Seriously? Does nobody know how to extend the configuration of Umbraco??

    I found a link on "AddConfigurationSection" but it isn't working either...(http://our.umbraco.org/wiki/reference/packaging/package-actions/community-made-package-actions/addconfigurationsection) and the explenation link at the bottom is broken... :-/

     

    ***************** UPDATE ******************

    Ok- so my problem was really not related to problems with the config files. :-/ My project didn't copy the dll over to the webserver, since the enviroment path to xcopy was corrupted (don't know why),,.

    So now my solution looks like this:

    web.config:

      </configSections>
    ...
    <section name="WoodbaseChimpMailer" type="WoodbaseMailer.BusinessLogic.Configuration.WoodbaseChimpMailer" requirePermission="false" />
    ...
      </configSections>
      ...
    <WoodbaseChimpMailer configSource="config\WoodbaseChimpMailer.config" />
    ...

     

    woodbaseChimpMailer.config

    <WoodbaseChimpMailer>
      <woodbaseMailer mailChimpSecureKey="*****************-us6" />
    </WoodbaseChimpMailer>

    woodbaseChimpMailer.cs

    namespace WoodbaseMailer.BusinessLogic.Configuration
    {
        public class WoodbaseChimpMailer : ConfigurationSection
        {
            public static WoodbaseChimpMailer GetConfig()
            {
                return ConfigurationManager.GetSection("WoodbaseChimpMailer") as WoodbaseChimpMailer;
            }

            [ConfigurationProperty("woodbaseMailer")]
            public WoodbaseMailer WoodbaseMailer
            {
                get
                {
                    return (WoodbaseMailer)this["woodbaseMailer"];
                }
                set
                { this["woodbaseMailer"] = value; }
            }
        }
        public class WoodbaseMailer : ConfigurationElement
        {
            [ConfigurationProperty("mailChimpSecureKey", DefaultValue = "", IsRequired = true)]
            public string MailChimpSecureKey
            {
                get
                {
                    return this["mailChimpSecureKey"] as string;
                }
            }
        }
    }

    and finaly loading it in the usercontrol:

    var mcKey = WoodbaseMailer.BusinessLogic.Configuration.WoodbaseChimpMailer.GetConfig().WoodbaseMailer.MailChimpSecureKey;

  • Jonas Eriksson 930 posts 1825 karma points
    Mar 23, 2014 @ 07:25
    Jonas Eriksson
    0
Please Sign in or register to post replies

Write your reply to:

Draft