.NET: List all AppSettings and AppSetting Values

9/11/2017 2:32:35 PM

Create a .NET dictionary containing all AppSetting keys and their related values.

//get dictionary of key/value pairs
var appSettings = System.Configuration.ConfigurationManager.AppSettings.AllKeys
                            .ToDictionary(key => key, key => System.Configuration.ConfigurationManager.AppSettings[key]); 


//display them on an mvc page
<h1>AppSettings</h1>
<div>
    @foreach (var pair in appSettings)
    {
        <div>
            @pair.Key | @pair.Value
        </div>
    }
</div>