How do I get .NET Feature Management to use config in User Secrets?

103 views Asked by At

I've got an ASPNET Core web app (.NET 6). I have User Secrets enabled and Feature Management enabled.

I would like to override some flags in my user secrets. However, by default, Feature Management reads from the FeatureManagement section of config, but doesn't read from user secrets.

How do I get FeatureManagement to read from user secrets as well as other config sources?

1

There are 1 answers

0
Steve Dunn On

Assuming you have set up your project for User Secrets, you simply have to call AddUserSecrets when building your configuration.

This is automatically done for you when using WebHost.CreateDefaultBuilder, but isn't if you manually initialise the builder (several hours could be lost if you forget this important fact - ask me how I know...)