In an ASP.NET project on .NET 6 the user secrets are only loaded when the environment used is Development
.
From https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=windows:
"WebApplication.CreateBuilder
initializes a new instance of the WebApplicationBuilder
class with preconfigured defaults. The initialized WebApplicationBuilder
(builder) provides default configuration and calls AddUserSecret
s when the EnvironmentName
is Development
."
Sometimes you need to run the project locally using a different environment, like Production
, or anything different from Development
. By default, the user secrets are not loaded in this situation. What should you do to load them?