In this article I will explain with an example, how to read (get) value from the AppSettings section of the Web.Config file in jQuery in ASP.Net using C# and VB.Net.
It is not possible to read the AppSetting value directly in jQuery and hence an AJAX call will be made to a WebMethod which will read the AppSetting value and return it to the Client Side script.
The AppSetting
The following AppSetting value will be read and fetched in JavaScript through AJAX call using jQuery.
    <add key="Name" value="Mudassar Khan"/>
HTML Markup
The HTML Markup consists of a TextBox and a HTML Button.
<asp:TextBox ID="txtKey" runat="server"></asp:TextBox>
<input id="btnGet" type="button" value="Get AppSetting" />
You will need to import the following namespace.
using System.Configuration;
Imports System.Configuration
The WebMethod
The GetAppSetting WebMethod accepts the parameter named key. The key parameter value is passed to the ConfigurationManager.AppSettings collection to fetch the value of the AppSettings Key.
Finally, the AppSettings value is returned.
Note: The method is declared as static (C#) and Shared (VB.Net) and also it is declared as WebMethod unless you do this you won’t be able to call the methods.
public static string GetAppSetting(string key)
    return ConfigurationManager.AppSettings[key];
Public Shared Function GetAppSetting(ByVal key As String) As String
    Return ConfigurationManager.AppSettings(key)
End Function
The jQuery AJAX call
The Get AppSetting Button has been assigned a jQuery click event handler and when the Button is clicked a jQuery AJAX call is made to the WebMethod.
The WebMethod which accepts the key value and returns the AppSettings value.
Finally, the AppSettings value is displayed using the JavaScript Alert Message Box.
<script type="text/javascript" src=""></script>
<script type="text/javascript">
    $(function () {
        $("#btnGet").click(function () {
                type: "POST",
                url: "Default.aspx/GetAppSetting",
                data: '{key: "' + $("#txtKey").val() + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                failure: function (response) {
                error: function (response) {
ASP.Net: Read (Get) AppSettings Key Value from Web.Config file in jQuery
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.