Green Grasso Holm
Green Grasso Holm

Reputation: 705

.NET Core precedence of configuration files by item or by section?

I have appsettings.json and environment specific settings like appsettings.development.json for my .NET application. Does the latter override the former at the item level or at the section level?

Suppose that appsettings.json has

"Foo": {
  "Setting1": "aaa",
  "Setting2": "bbb"
  }

and that appsettings.Development.json has

"Foo": {
  "Setting1": "zzz"
}

When I'm executing my application in my development environment, what will be returned by Configuration.GetSection("Foo").GetValue("Setting2")?

Upvotes: 0

Views: 1854

Answers (1)

Green Grasso Holm
Green Grasso Holm

Reputation: 705

That was one of those questions that I realized ten minutes later was easy enough to test in the setup I already have. The overrides are per-setting, not per-section. The value of Foo.Setting2 = "bbb" would from appsettings.json would pass through to the app. Well, here it is for reference for anyone else with the same question.

Upvotes: 2

Related Questions