In this article I will explain with an example, how to read (get) key values of AppSettings section from ASP.Net Web.Config file using C# and VB.Net.
In ASP.Net Web Applications, one has to reference the System.Configuration Assembly in order to read AppSetting values from the Web.Config file.
 
 
Adding System.Configuration reference
The very first thing you need to do is to add reference of the System.Configuration Assembly to the project in the following way.
1. Right click on the project and click Add Reference option from the Context Menu.
Read (Get) AppSettings Key Value from Web.Config file in ASP.Net using C# and VB.Net
 
2. From the Add Reference dialog box, click on .Net Tab and look for System.Configuration assembly. Once you find it simply select and click OK.
Read (Get) AppSettings Key Value from Web.Config file in ASP.Net using C# and VB.Net
 
3. Once the reference is added, it will be shown in the References folder of the Solution Explorer.
Read (Get) AppSettings Key Value from Web.Config file in ASP.Net using C# and VB.Net
 
 
Namespaces
You will need to import the following namespace.
C#
using System.Configuration;
 
VB.Net
Imports System.Configuration
 
 
Reading AppSettings value from Web.Config file using C# and VB.Net
Once the reference is added, you can read the AppSettings value from the Web.Config file in the following way.
C#
string name = ConfigurationManager.AppSettings["Name"];
 
VB.Net
Dim name As String = ConfigurationManager.AppSettings("Name")