Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7643343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:25:30+00:00 2026-05-31T09:25:30+00:00

This is copied example from: How to read custom config section in app.config in

  • 0

This is copied example from:

How to read custom config section in app.config in c#

I want to read following custom section from app.config:

<StartupFolders>    
   <Folders name="a">
      <add folderType="Inst" path="c:\foo" />
      <add folderType="Prof" path="C:\foo1" />      
   </Folders>
   <Folders name="b">
      <add folderType="Inst" path="c:\foo" />
      <add folderType="Prof" path="C:\foo1" />      
   </Folders> 
</StartupFolders>

And this is my case too. However, I don’t want to create custom class for handling values, defining this class in web.config, and then finally using it. It is heavy-weight for my needs.

Instead I would like to do something very simple — retrieve a section as XML. Then I could use regular Linq.Xml to parse it. This way, I don’t need to create new classes per each section, I don’t need to declare them. For my purpose it is sufficient on one hand, and minimal at the other (I do it once, key-value mapper for nested sections). I.e. perfect.

The only missing piece is (my question) — how to get a web.config section as XML?
Note about the section:

  • it cannot be encoded, because it has to be edited by hand
  • it cannot be serialized for the same reason

So I am not looking for a workaround how to squeeze entire section as value in appSettings, but I am really looking for a method to get proper section as XML.

I would like to get it from ConfigManager (!), because this way I don’t have to deal with resolving which web.config should I read, etc. I.e. less chance to make mistake than mimicing web.config precedence manually.


Forgive me for reminding this, but please avoid “answers”, you shouldn’t do this, use custom class per each section, etc. I already considered this, and opted against it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:25:32+00:00Added an answer on May 31, 2026 at 9:25 am

    I think you either have to do it manually and load the Web config into memory:

    XmlDocument doc = new XmlDocument();
    doc.Load(Server.MapPath("~/Web.config")); 
    

    Or you will need to create the custom configuration sections you want to avoid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I copied this code from an example . I've read it 100 times. Array.prototype.map
I'm at a loss debugging this code. I copied the example from a guide,
I copied this code from another post. I tried the example, however, I am
I copied this code from the libjpeg example and im passing it standard files;
Still fighting with templates. In this example, despite the fact that is copied straight
this is copied from http://www.zenspider.com/ZSS/Products/RubyInline/Readme.html , the home of rubyinline, adding/moding as indicated in
I have this sample code for async operations (copied from the interwebs) public class
I have the following code which i copied from here : /*************************************************************************** * _
I decided to give Nokogiri a try, and copied the following program straight from
Problem: I need to write/read objects from a file.This because I need to write/read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.