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

  • Home
  • SEARCH
  • 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 6790587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:44:34+00:00 2026-05-26T17:44:34+00:00

I have this in a web.config : <MySection> <Setting1 Value=10 /> <Setting2 Value=20 />

  • 0

I have this in a web.config :

<MySection>
    <Setting1 Value="10" />
    <Setting2 Value="20" />
    <Setting3 Value="30" />
    <Setting4 Value="40" />
</MySection>

I’d like read the all section “MySection” and get all value to a List<string> (ex : “10”,”20″,”30″)

Thanks,

  • 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-26T17:44:35+00:00Added an answer on May 26, 2026 at 5:44 pm

    First of all, I recommend use to use Unity Configuration.

    Code:

    public class MySection : ConfigurationSection
    {
        protected static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
    
        private static ConfigurationProperty propElements = new ConfigurationProperty("elements", typeof(MyElementCollection), null, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsDefaultCollection);
    
        static BotSection()
        {
            properties.Add(propElements);
        }
    
        [ConfigurationProperty("elements", DefaultValue = null, IsRequired = true)]
        [ConfigurationCollection(typeof(MyElementCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
        public MyElementCollection Elements
        {
            get
            {
                return (MyElementCollection)this[propElements];
            }
            set
            {
                this[propElements] = value;
            }
        }
    }
    
    public class MyElementCollection : ConfigurationElementCollection, 
                                       IEnumerable<ConfigurationElement> // most important difference with default solution
    {
        public void Add(MyElement element)
        {
            base.BaseAdd(element);
        }
    
        public void Clear()
        {
            base.BaseClear();
        }
    
        protected override ConfigurationElement CreateNewElement()
        {
            return new MyElement();
        }
    
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((MyElement)element).Id;
        }
    
        IEnumerator<MyElement> IEnumerable<MyElement>.GetEnumerator()
        {
            return this.OfType<MyElement>().GetEnumerator();
        }
    }
    
    public class MyElement : ConfigurationElement
    {
        protected static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
    
        private static ConfigurationProperty propValue= new ConfigurationProperty("value", typeof(int), -1, ConfigurationPropertyOptions.IsRequired);
    
        public int Value
        {
            get
            {
                return (int)this[propValue];
            }
            set
            {
                this[propValue] = value;
            }
        }
    }
    

    Config:

    <configuration>
        <configSections>
            <section name="MySection" type="MySection, MyAssembly"/>
        </configSections>
        <MySection>
            <elements>
                <clear />
                <add value="10" />
                <remove value="10" />
                <add value="20" />
                <add value="30" />
            </elements>
        </MySection>
    </configuration>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I have a relative path in the web.config file. This value is
I have this in my web.config file (edited to reflect some changes): <configSections> <section
In my web.config I have this: <system.web> <authentication mode=Forms> <forms loginUrl=Login.aspx protection=All path=/ timeout=30/>
I have this section in the Web.config for my MVC3 application: <authentication mode=Forms> <forms
I have this on my web.config file: <authentication mode=Forms> <forms loginUrl=login.aspx defaultUrl=Venues.aspx /> </authentication>
Weired problem! ASP.NET Session expires instantly. In my web.config I have this session settings:
In web.xml I have this <session-config> <session-timeout>2</session-timeout> </session-config> <listener> <listener-class>myapplication.SessionListener</listener-class> </listener> In the SessionListener.java
Please refer to this post. I have become able to configure my web.config file
I have this url: http://www.site.com/products-book_1.aspx?promo=free Here is what I have in my web.config for
I have this rewrite rule in my web.config: <RewriterRule> <LookFor>/RecoverPassword.aspx</LookFor> <SendTo>/Logon.aspx?t=pr</SendTo> </RewriterRule> Well, the

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.