Store Your Code Now
Tools: String Manipulations Find Dupes My IP Json Formatter Lorem Ipsum More...
Discussion Options

.NET: List all AppSettings and AppSetting Values

9/11/2017 10:32:35 AM by: CodeLocker

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

View Copy: Content Copied
//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>
Copy: Content Copied
×

Get Coding

Store your first code or add more code to your collection.
You must login to report abuse. ×