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 7814565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:14:06+00:00 2026-06-02T05:14:06+00:00

I plan to set up configuration keys for FormFields, QueryString parameters etc. In my

  • 0

I plan to set up configuration keys for FormFields, QueryString parameters etc. In my web.config I have setting as follows:

<WhiteListPaametersGroup>
  <WhiteListPaameters>
    <FormField1>EVENTVALIDATION</FormField1>
    <FormField2>VIEWSTATE</FormField2>
    <FormField3>Button1</FormField3>

    <QueryString1>firstname</QueryString1>
    <QueryString2>lastname</QueryString2>

  </WhiteListPaameters>
</WhiteListPaametersGroup>

Then in my code, I read the value as follows:

Dictionary<string, string> parameters = new Dictionary<string,string>();

foreach (XmlNode n in section.ChildNodes)
{
    parameters.Add(n.Name, n.InnerText);
}

Is there a better way of storing this. Later on, I want to be able to go through dictionary like object, and be able to get settings for FormFields, Querystrings etc.

Please let me know if I could write it cleaner.

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-06-02T05:14:08+00:00Added an answer on June 2, 2026 at 5:14 am

    You can use XML serialization to store your settings and restore them directly into an object. It’s not perfect but very easy to set up and gives you object save/restore.

    Have this class (properties must be public):

    public class WhiteListParameters
    {
        public string FormField1 { get; set; }
        public string FormField2 { get; set; }
        public string FormField3 { get; set; }
    
        public string QueryString1 { get; set; }
        public string QueryString2 { get; set; }
    }
    

    To save it to XML file run this code:

    WhiteListParameters parms = new WhiteListParameters
                                    {
                                        FormField1 = "EVENTVALIDATION",
                                        FormField2 = "VIEWSTATE",
                                        FormField3 = "Button1",
                                        QueryString1 = "firstname",
                                        QueryString2 = "lastname"
                                    };
    
    using(StreamWriter sw = new StreamWriter("C:\\temp\\config.xml"))
    {
        XmlSerializer xs = new XmlSerializer(typeof (WhiteListParameters));
        xs.Serialize(sw, parms);
        sw.Close();
    }
    

    To read it back into an object:

    using(StreamReader sr = new StreamReader("c:\\temp\\config.xml"))
    {
        XmlSerializer xs = new XmlSerializer(typeof (WhiteListParameters));
        WhiteListParameters parms = (WhiteListParameters) xs.Deserialize(sr);
        sr.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For my app, I have a fairly complex set of configuration options that user
In SQL Server 2005 I have a maintenance plan set up to back up
I plan to be storing all my config settings in my application's app.config section
I plan to have 2 projects. 1. mbtech.crm.mvc 2. mbtech.crm.tests I will have a
This time, I'm gonna create a math problems. I plan to have a dictionary
As a paper saving drive throughout the organization, we plan to set 2 page
i plan to set a checkbox with selected option in my form. but i
I currently have a web project developed with Codeigniter. My production environment works as
I plan to introduce a set of standards for writing unit tests into my
I'm setting up a postwwwacct script to set up a WordPress installation with some

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.