Gayan Fonseka
1 min readMay 21, 2019

--

When we did a .net core service we found that the appsettings.json was not read and hence the variable we null. If your normal configuration builder is as below,

var builder = new ConfigurationBuilder()

.SetBasePath(Directory.GetCurrentDirectory())

.AddJsonFile(“appsettings.json”, optional: true, reloadOnChange: true);

replace the same with

var builder = new ConfigurationBuilder()

.SetBasePath(System.AppDomain.CurrentDomain.BaseDirectory)

.AddJsonFile(“appsettings.json”, optional: true, reloadOnChange: true);

and give it a try. Sorry I could find that in the your code in a quick glance to show the exact location.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Gayan Fonseka
Gayan Fonseka

Responses (1)

Write a response