Copied to clipboard

Flag this post as spam?

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


  • Duke Maximus 23 posts 20 karma points
    May 19, 2009 @ 07:59
    Duke Maximus
    0

    Custom Section in web.config

    Hi,

    I'm not sure which section this should reside.
    I've got a custom section declared within my web.config.

    [code]


    [/code]

    and this after

    [code][/code]

    When I try and getSection("MyAppSettings"), the object returns as null. Does anyone have an idea where I'm going wrong. I tried this on my local machine and it worked fine.

    Thanks in advance!

  • Robert Oswald 72 posts 24 karma points
    May 20, 2009 @ 14:06
    Robert Oswald
    0

    this is working for me:
    [code]WebConfigurationManager.GetSection("system.net/mailSettings/smtp") as SmtpSection[/code]
    what looks strange to me is the "NameValueFileSectionHandler" that you're using:
    i think (according to this msdn entry) it's not what you are looking for.

    maybe you wanna try the KeyValueConfigurationCollection

  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 00:07
    Duke Maximus
    0

    Hi roberkules,

    I moved the

    [code][/code]

    to the end of the web config file and it's working now! I had it just under the configSections declaration before. I can't believe I didn't try that in the first place! :d/

  • Robert Oswald 72 posts 24 karma points
    May 22, 2009 @ 17:33
    Robert Oswald
    0

    if you have time you could also look into creating custom ConfigurationSections with custom ConfigurationElements

    i'm using it now and it's nice because you are not limited to name/value collections and you can even specify the type of the values

    cheers,
    robert

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies