最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

.net - UserSecrets per LaunchProfile - Stack Overflow

matteradmin5PV0评论

I have different launchProfiles in my dotnet project and I would like the passwords to be saved in the secrets.json, but I do not manage to do so.

So the launchsettings look like this:

{
    "profiles": {
        "httpsSomethingElse": {
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "mariadb_database": "something1",
                "mariadb_username": "something2",
                "mariadb_password": "something3",
               
            }
        },
        "httpsSomething": {
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "mariadb_database": "something4",
                "mariadb_username": "something5",
                "mariadb_password": "something6",
               
            }
        },
        "httpsLocal": {
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "mariadb_database": "something8",
                "mariadb_username": "something7",
                "mariadb_password": "something0",
               
            }
        },
    },
}

Maybe I am failing to do the format of the secrets.json properly, but none of these formats here works:

{
  "httpsSomething": {
    "environmentVariables": {
      "mariadb_username": "something",
      "mariadb_password": "something",
      "mqtt_hostname": "something"
    }
  },
  "profile": {
      "httpsSomething": {
        "environmentVariables": {
          "mariadb_username": "something",
          "mariadb_password": "something",
          "mqtt_hostname": "something"
        }
      },
  }
  "httpsSomething__environmentVariables__mariadb_username": "something",
  "httpsSomething__environmentVariables__mariadb_password": "something",
  "httpsSomething__environmentVariables__mqtt_hostname": "something",
  }
}

The reason why I tried all sorts of different approaches here is because different manuals in the internet showed different ways of doing it.

What is the proper way to do so? Maybe its not supported by secrets.json in general?

Post a comment

comment list (0)

  1. No comments so far