Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Reading Web.Config

Reading Web.Config

Scheduled Pinned Locked Moved ASP.NET
htmlxmljsonquestionworkspace
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gerry
    wrote on last edited by
    #1

    Hi, I want to create a class library that will read certain sections of my web.config, not just in the configuration section, how can I do this without doing the cheap and nastly way, reading the whole web.config into an xml dom and parsing. Thanks, Gerry.

    P 1 Reply Last reply
    0
    • G Gerry

      Hi, I want to create a class library that will read certain sections of my web.config, not just in the configuration section, how can I do this without doing the cheap and nastly way, reading the whole web.config into an xml dom and parsing. Thanks, Gerry.

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      Gerry wrote: how can I do this without doing the cheap and nastly way, reading the whole web.config into an xml dom and parsing. First you return a NameValueCollection of your custom config section; NameValueCollection config = (NameValueCollection) ConfigurationSettings.GetConfig("mygroup/nestedgroup/mysection"); Then you access the NameValueCollection like so; config["key_one"] It is all in MSDN

      Paul Watson
      Bluegrass
      Cape Town, South Africa

      Shog9 wrote: Everybody just wants to be naked and famous, Paul.

      G 1 Reply Last reply
      0
      • P Paul Watson

        Gerry wrote: how can I do this without doing the cheap and nastly way, reading the whole web.config into an xml dom and parsing. First you return a NameValueCollection of your custom config section; NameValueCollection config = (NameValueCollection) ConfigurationSettings.GetConfig("mygroup/nestedgroup/mysection"); Then you access the NameValueCollection like so; config["key_one"] It is all in MSDN

        Paul Watson
        Bluegrass
        Cape Town, South Africa

        Shog9 wrote: Everybody just wants to be naked and famous, Paul.

        G Offline
        G Offline
        Gerry
        wrote on last edited by
        #3

        That's fine but it's not in the configuration section. Example: I want to read the name and path attributes of the forms element. Gerry.

        P 1 Reply Last reply
        0
        • G Gerry

          That's fine but it's not in the configuration section. Example: I want to read the name and path attributes of the forms element. Gerry.

          P Offline
          P Offline
          Paul Watson
          wrote on last edited by
          #4

          Gerry wrote: I want to read the name and path attributes of the forms element. Ahhh ok. If you are wanting a more general way of accessing any value in the web.config then yes, you probably have to use the Xml classes to get at it.

          Paul Watson
          Bluegrass
          Cape Town, South Africa

          Shog9 wrote: Everybody just wants to be naked and famous, Paul.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups