Answers for "how to access appsettings.json variables"

C#
2

use appsettings.json in console app

All that’s required is to add the following NuGet packages and an appsettings.json file.

Microsoft.Extensions.Configuration
Microsoft.Extensions.Configuration.FileExtensions
Microsoft.Extensions.Configuration.Json

The appsettings.json files “Copy to Output Directory” property should also be set to “Copy if newer” so that the application is able to access it when published.
Posted by: Guest on March-10-2020
0

.net using appsettings variables

var connectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
connectionString.Expand() // returns "server=db01.mycompany.com;uid=uid;pwd=pwd;Initial Catalog=master;"
Posted by: Guest on January-05-2021

Code answers related to "how to access appsettings.json variables"

C# Answers by Framework

Browse Popular Code Answers by Language