Solved

Write value to web.config at runtime

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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