Solved

Write value to web.config at runtime

Posted on 2011-09-14
2
140 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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