I am having a problem when trying to read user secrets. My code in startup.cs is as follows:
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json",
optional: false,
reloadOnChange: true);
if (env.IsDevelopment())
{
builder.AddUserSecrets<Startup>(false);
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
Reading from appsettings.json and from environment variables works fine, but no matter what I put in the secrets.json file no values are read from it. The value of UserSecretsId in the project file is correct and env.IsDevelopment() is true.
Configuration contains three providers. One JsonConfigurationProvider containing the Data from appsettings.json, one EnvironmentVariablesConfigurationProvider containing the values from environment variables and one JsonConfigurationProvider which has no data. I presume the latter one is the one from adding user secrets. But why is it empty?