C#C
C#2y ago
Ares

dotnet user secrets not working

So basically, I am using Docker and I am trying to make it so that for development I can use
user secrets
to store things like
ClientId
,
ClientSecrets
and
DatabaseConnection
instead of using
Appsettings.json
. so I store all the things I need for development in
secrets.json
And then in
Program.cs`, it should read from the user secrets instead of 
Appsettings.json
, i actually deleted appsettings.json. Here is what I did:

```dotnet user-secrets set "GoogleKeys:ClientSecret" "123123"
  dotnet user-secrets set "GoogleKeys:ClientId" "456456"
dotnet user-secrets set "ConnectionStrings:DatabaseConnection" "Host=<host>;Port=5432;Database=<database>;Username=<username>;Password=<password>"
```
so now I see them when i do 
dotnet user-secrets list
:
```
GoogleKeys:ClientSecret = 123123
GoogleKeys:ClientId = 456456
ConnectionStrings:DatabaseConnection = Host=<host>;Port=<port>;Database=<database>;Username=<username>;Password=<password>```

I dont see them in secrets.json for some reason but I guess thats okay cause the command returned them. I also know the secrets.json is hooked up cause when i go to the 
.csproj``, :

<UserSecretsId>02aa0af3-c478-4f3a-addb-31dce40f9f96</UserSecretsId>


the value in here matches the value in my local directory. there is an image attached that shows that they matched.
image.png
Was this page helpful?