Skip to content

Mixed appsettings.json & appsettings.development.json #3735

@karelz

Description

@karelz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions