DEV Community

Kamlesh Singh
Kamlesh Singh

Posted on

App secrets in dot net core

Create new application in dotnet core using CLI or Visual Studio IDE
Go to project directory and run below command

dotnet user-secrets init
dotnet user-secrets set "Key_name" "key_value"
Enter fullscreen mode Exit fullscreen mode

now get value using
Environment.GetEnvironmentVariable("Key_name");
or
private readonly IConfiguration _config;
public Classtest(IConfiguration config)
{
_config = config;
}

string _key=_config["Key_name"]

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay