C
C#15mo ago
mitchelldirt

✅ How to use secret manager asp.net

Good morning, was wondering how I can import a secret into a C# file using the secret manager. I initialized it and set a secret and I can access the configuration through the Program.cs file, but I'm not sure how I can pass it to my other C# file where the logic that necessitates the secrets is happening.
1 Reply
mitchelldirt
mitchelldirtOP15mo ago
Oh my goodness. Not sure why I couldn't find this anywhere, but I ended up using
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
This allowed me to grab config secrets by doing config["key"]
Want results from more Discord servers?
Add your server