Solved

Write value to web.config at runtime

Posted on 2011-09-14
2
138 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:knowlton
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:knowlton
ID: 36544568
thx
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

820 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