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?
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.
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...
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),,.
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;
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?
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...
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
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
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;
Thanks for the complete example Martin. Also for ref http://mike-ward.net/blog/post/00830/creating-custom-configuration-sections-in-web-config .
is working on a reply...