?
Solved

Write value to web.config at runtime

Posted on 2011-09-14
2
Medium Priority
?
141 Views
Last Modified: 2012-05-12
Is this correct?

if (System.Configuration.ConfigurationManager.AppSettings["TEXTBOOK_ALLOW_BUY"] != null)
        {
            if (cballowbuytextbooks.Checked)
            {
                System.Configuration.ConfigurationManager.AppSettings.Set("TEXTBOOK_ALLOW_BUY","YES");
            }
            else
            {
                System.Configuration.ConfigurationManager.AppSettings.Set("TEXTBOOK_ALLOW_BUY", "NO");
            }
        }

Open in new window




What if the name value pair does not exist?  Will the call to AppSettings.Set(  )   create the entry if it does not exist?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
disrupt earned 2000 total points
ID: 36537202
No that will not create the entry if it does not exist:

Look at this:

http://forums.asp.net/t/1690754.aspx/1?Modify+Web+config
0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 36544568
thx
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question