How To Read Key/Value Pairs From AppSettings?
Application parameters in web.config file can be very useful. This is an example of appSettings section in web.config that contains two parameters:
[ XML ]
<configuration>
<appSettings>
<add
key="FirstParameter"
value="5"
/>
<add
key="SecondParameter"
value="50"/>
</appSettings>
To read application parameters from appSettings section in web.config file, you can use this code:
[ C# ]
string FirstParameter = System.Configuration.ConfigurationManager.AppSettings["FirstParameter"];
[ VB.NET ]
Dim FirstParameter As String = _
System.Configuration.ConfigurationManager.AppSettings("FirstParameter")
Related articles:
1. How to set up an ASP.NET web site with IIS
2. How To Avoid Load Of Http Handler From Root In Virtual Dir