<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Bilal Haidar [MVP] : Configuration in ASP.NET 2.0</title><link>http://msmvps.com/blogs/simpleman/archive/tags/Configuration+in+ASP.NET+2.0/default.aspx</link><description>Tags: Configuration in ASP.NET 2.0</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Add AppSettings Keys Programatically</title><link>http://msmvps.com/blogs/simpleman/archive/2005/06/23/54733.aspx</link><pubDate>Thu, 23 Jun 2005 21:32:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:54733</guid><dc:creator>simple</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/simpleman/rsscomments.aspx?PostID=54733</wfw:commentRss><comments>http://msmvps.com/blogs/simpleman/archive/2005/06/23/54733.aspx#comments</comments><description>&lt;P&gt;In ASP.NET 2.0 Beta 2, two new configuration classes have been added:&lt;/P&gt;
&lt;P&gt;1- &lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxlrfConfigurationManagerObject.asp"&gt;ConfigurationManager&lt;/A&gt;&lt;/STRONG&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Used to update sections inside the App.Config file.&lt;/P&gt;
&lt;P&gt;2- &lt;STRONG&gt;&lt;A href="http://msdn2.microsoft.com/library/ms151430(en-us,vs.80).aspx"&gt;WebConfigurationManager&lt;/A&gt;&lt;/STRONG&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Used to update setions inside Web.Config file.&lt;/P&gt;
&lt;P&gt;To see how to add some keys to the AppSettings section in the web.config file, check the code below:&lt;/P&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;Configuration configFile &lt;FONT color=#ff0033&gt;=&lt;/FONT&gt; &lt;BR&gt;                  WebConfigurationManager.OpenWebConfiguration(&lt;FONT color=#006080&gt;"~"&lt;/FONT&gt;);
AppSettingsSection AppSection &lt;FONT color=#ff0033&gt;=&lt;/FONT&gt; &lt;BR&gt;                  configFile.GetSection(&lt;FONT color=#006080&gt;"appSettings"&lt;/FONT&gt;) &lt;FONT color=#0000ff&gt;as&lt;/FONT&gt; AppSettingsSection;
AppSection.Settings.Add(&lt;BR&gt;                 &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; KeyValueConfigurationElement(&lt;FONT color=#006080&gt;"SMTP"&lt;/FONT&gt;, &lt;FONT color=#006080&gt;"mail.bhaidar.net"&lt;/FONT&gt;)&lt;BR&gt;                       );    
configFile.Save();&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT face="Times New Roman" size=3&gt;The above code would add the following line to the appSettings section.&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;appSettings&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;    &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;add&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;key&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="SMTP"&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;value&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="mail.bhaidar.net"&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;/&amp;gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#800000&gt;/appSettings&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face="Times New Roman" color=#000000 size=3&gt;Make sure to include:&lt;/FONT&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT color=#0000ff&gt;using&lt;/FONT&gt; System.Web.Configuration;&lt;/PRE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT face="Times New Roman" size=3&gt;Hope that helps you.&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 10pt; BACKGROUND: #ffffff; COLOR: black; FONT-FAMILY: Courier New, Courier, Monospace"&gt;&lt;FONT face="Times New Roman" size=3&gt;Regards&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=54733" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/simpleman/archive/tags/Configuration+in+ASP.NET+2.0/default.aspx">Configuration in ASP.NET 2.0</category></item><item><title>Configuration Section handler and the validator classes to validate the section </title><link>http://msmvps.com/blogs/simpleman/archive/2005/06/23/54666.aspx</link><pubDate>Thu, 23 Jun 2005 16:19:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:54666</guid><dc:creator>simple</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/simpleman/rsscomments.aspx?PostID=54666</wfw:commentRss><comments>http://msmvps.com/blogs/simpleman/archive/2005/06/23/54666.aspx#comments</comments><description>&lt;P&gt;A great post about reading a ConfigurationSection in asp.net 2.0 by Fredrik Normen.&lt;/P&gt;
&lt;P&gt;Check the post @ : &lt;A href="http://fredrik.nsquared2.com/viewpost.aspx?PostID=253&amp;showfeedback=true"&gt;http://fredrik.nsquared2.com/viewpost.aspx?PostID=253&amp;showfeedback=true&lt;/A&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=54666" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/simpleman/archive/tags/Configuration+in+ASP.NET+2.0/default.aspx">Configuration in ASP.NET 2.0</category></item><item><title>ConfigurationManager Class in ASP.NET 2.0</title><link>http://msmvps.com/blogs/simpleman/archive/2005/06/23/54661.aspx</link><pubDate>Thu, 23 Jun 2005 16:07:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:54661</guid><dc:creator>simple</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/simpleman/rsscomments.aspx?PostID=54661</wfw:commentRss><comments>http://msmvps.com/blogs/simpleman/archive/2005/06/23/54661.aspx#comments</comments><description>&lt;P&gt;Fredrik Normen explains the ConfigurationManager in details.&lt;/P&gt;
&lt;P&gt;Check his post @ : &lt;A href="http://fredrik.nsquared2.com/viewpost.aspx?PostID=252&amp;showfeedback=true"&gt;http://fredrik.nsquared2.com/viewpost.aspx?PostID=252&amp;showfeedback=true&lt;/A&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=54661" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/simpleman/archive/tags/Configuration+in+ASP.NET+2.0/default.aspx">Configuration in ASP.NET 2.0</category></item></channel></rss>