are there any API methods/functions to expose access to a custom configfile (placed in /config) used by a usercontrol? Or do you write your own customcode for this?
Did you already found this Config Tree package? If you can't use it, it comes with the source so you can see how this is handled. It will be custom code there is no API for this.
Sorry, I may have been unclear in my question. I do not need to display the content of a custom configfile in a usercontrol. I was looking for a way to have my usercontrol use a custom configfile for a couple of settings that may need tweeking once in production. Therefore, my question was wheter this was something that had support in the Umbraco API or if people wrote their own configcode when placing configfiles in /config.
You have to write your own configcode to access the configfiles.Only class that will help you is the xmlHelper class which lives in the umbraco dll. Then you can get an XML document object using xmlHelper.OpenAsXmlDocument("~/config/yourconfigfile.xml")
Don't parse XML documents to simulate config files, use the .NET config sections through the class I linked in the above post.
Then you'll get proper validation from the .NET framework for your config file and modifying it will automatically recycle the app pool (unless you explicitly disable that, I recommend you don't though :P).
I'm creating a user control that needs to access settings in a custom .config file in the /config folder. I understand the importance / convenience of accesing it via the built in .NET config sections classes so want to do it using this approach.
Is it possible to do this without adding references in the main web.config? How does Umbraco handle config files like dashBoard.config or formHandlers.config as there is no reference / declaration of these sections in the web.config file?
API for custom configfile access
Hi,
are there any API methods/functions to expose access to a custom configfile (placed in /config) used by a usercontrol? Or do you write your own customcode for this?
Thankful for any help // Magnus
Hi Magnus,
Did you already found this Config Tree package? If you can't use it, it comes with the source so you can see how this is handled. It will be custom code there is no API for this.
Cheers,
Richard
What do you need to display it in a user control for? Are you implementing ConfigurationSection, that makes returning data from the config file easy: http://msdn.microsoft.com/en-us/library/system.configuration.configurationsection.aspx
Sorry, I may have been unclear in my question. I do not need to display the content of a custom configfile in a usercontrol. I was looking for a way to have my usercontrol use a custom configfile for a couple of settings that may need tweeking once in production. Therefore, my question was wheter this was something that had support in the Umbraco API or if people wrote their own configcode when placing configfiles in /config.
//Magnus
HI Magnus,
You have to write your own configcode to access the configfiles.Only class that will help you is the xmlHelper class which lives in the umbraco dll. Then you can get an XML document object using xmlHelper.OpenAsXmlDocument("~/config/yourconfigfile.xml")
Cheers,
Richard
Don't parse XML documents to simulate config files, use the .NET config sections through the class I linked in the above post.
Then you'll get proper validation from the .NET framework for your config file and modifying it will automatically recycle the app pool (unless you explicitly disable that, I recommend you don't though :P).
Thanks everyone! :)
Hi,
I'm creating a user control that needs to access settings in a custom .config file in the /config folder. I understand the importance / convenience of accesing it via the built in .NET config sections classes so want to do it using this approach.
Is it possible to do this without adding references in the main web.config? How does Umbraco handle config files like dashBoard.config or formHandlers.config as there is no reference / declaration of these sections in the web.config file?
Thanks,
Simon
is working on a reply...