Copied to clipboard

Flag this post as spam?

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


  • Magnus Jonsson 33 posts 53 karma points
    Sep 20, 2010 @ 21:50
    Magnus Jonsson
    0

    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

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Sep 20, 2010 @ 22:57
    Richard Soeteman
    0

    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

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 21, 2010 @ 00:18
    Aaron Powell
    0

    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

  • Magnus Jonsson 33 posts 53 karma points
    Sep 21, 2010 @ 09:19
    Magnus Jonsson
    0

    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

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Sep 21, 2010 @ 09:27
    Richard Soeteman
    0

    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

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 21, 2010 @ 09:41
    Aaron Powell
    0

    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).

  • Magnus Jonsson 33 posts 53 karma points
    Sep 21, 2010 @ 09:43
    Magnus Jonsson
    0

    Thanks everyone! :)

  • Simon Osborne 108 posts 150 karma points
    Aug 14, 2011 @ 00:48
    Simon Osborne
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft