Solved

Write value to web.config at runtime

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now