From the course: Managing App Secrets in .NET Core

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Accessing secrets

Accessing secrets - ASP.NET Core Tutorial

From the course: Managing App Secrets in .NET Core

Start my 1-month free trial

Accessing secrets

- On the last part we learned how to set app secrets, and on this part we are going to learn how to access them. To access the app secrets we can either use the key values that we define when we set a secret or, we can create a POCO class only with the secret properties and then access them that way. So, let us go to our project and see how we can access app secrets. Before we access any of the secrets, let us see which secrets do we have in an application. Now one way is to go to the app secrets file and then read all the secrets from there, or we can use the package manager console. So for them go to our package manager console and in here write dotnet user-secrets, and then list. Press Enter. We see that we get an error, and that's right because we need to specify a project since in our solution we have two projects. So let us write a comment one more time, - -project and then secrets. So we see that inside this project we have five secrets. Now how can we access any of these…

Contents