Skip to content

Mixed appsettings.json & appsettings.development.json #792

@Tratcher

Description

@Tratcher

From @karelz on October 27, 2018 15:55

From @johndhunter on October 27, 2018 13:10

I seem to be getting results from both appsettings.json and appsettings.development.json when I use the following:
var users = _configuration.GetSection("AdministrationUsers");

my appsettings.development.json is like:

"AdministrationUsers": [
    {
      "Email": "Development@somewhere.com",
      "PasswordHash": "AQAAAAEAACcQAAAAEJqwmeQsHrAZySU8kIV8BJPsEGirVXddDhU0EWabuGdGzNj93/9MXQ17hsFhRENbqA=="
    }
  ]

whilst my appsettings.json is like:

"AdministrationUsers": [
    {
      "Email": "Production@somewhere.com",
      "PasswordHash": "AQAAAAEAACcQAAAAEJqwmeQsHrAZySU8kIV8BJPsEGirVXddDhU0EWabuGdGzNj93/9MXQ17hsFhRENbqA=="
    },
    {
      "Email": "Support@somewhere.com",
      "PasswordHash": "AQAAAAEAACcQAAAAEJqwmeQsHrAZySU8kIV8BJPsEGirVXddDhU0EWabuGdGzNj93/9MXQ17hsFhRENbqA=="
    }
  ]

With ASPNETCORE_ENVIRONMENT set to Development and using the default CreatedDefaultBuilder and no other settings - I see the Email for Development@somewhere.com AND the Email for Support@somewhere.com - suggesting the list that is built up seems to be shared. I.e. I would expect the results (i.e. the entire collection) to have come from only one of the files - but maybe that is how it's supposed to work - if so, perhaps the configuration docs need an update pertaining to collections.

Copied from original issue: dotnet/corefx#33091

Copied from original issue: dotnet/aspnetcore#3735

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions