b9c408f82a
Fixes #6523 [Internal Review Topic](https://review.docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-1.0&branch=pr-en-us-6528) Tiny nits in the app secrets update: "or later" and a couple of comma splices. What I wrote for another version of this was more explicit. I'm concerned that the current version doesn't tell devs exactly why/how `AddUserSecrets` is added, and it doesn't say that if `CreateDefaultBuilder` isn't used that they'll still need to do it manually. Starting with ... > \- Add the user secrets configuration source to the `Startup` constructor: > Add the user secrets configuration source with a call to \[AddUserSecrets](/dotnet/api/microsoft.extensions.configuration.usersecretsconfigurationextensions.addusersecrets) in the `Startup` constructor: > > \[!code-csharp\[](app-secrets/samples/1.1/UserSecrets/Startup.cs?name=snippet_StartupConstructor&highlight=5-8)] > ::: moniker-end > ::: moniker range=">= aspnetcore-2.0" > When a project calls \[CreateDefaultBuilder](/dotnet/api/microsoft.aspnetcore.webhost.createdefaultbuilder) to initialize a new instance of the host with preconfigured defaults, \[AddUserSecrets](/dotnet/api/microsoft.extensions.configuration.usersecretsconfigurationextensions.addusersecrets) is called when the \[EnvironmentName](/dotnet/api/microsoft.aspnetcore.hosting.ihostingenvironment.environmentname) is \[Development](/dotnet/api/microsoft.aspnetcore.hosting.environmentname.development): > > \[!code-csharp\[](app-secrets/samples/2.1/UserSecrets/Program.cs?name=snippet_CreateWebHostBuilder&highlight=2)] > > When `CreateDefaultBuilder` isn't called during host construction, add the user secrets configuration source with a call to \[AddUserSecrets](/dotnet/api/microsoft.extensions.configuration.usersecretsconfigurationextensions.addusersecrets) in the `Startup` constructor: > > \[!code-csharp\[](app-secrets/samples/1.1/UserSecrets/Startup.cs?name=snippet_StartupConstructor&highlight=5-8)] > ::: moniker-end Snippet the call to `CreateDefaultBuilder` to show it (line 2 is highlighted) ... ```csharp #region snippet_CreateWebHostBuilder public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>(); #endregion ``` ... and the sample naming issue remains ("1.1" and "2.1" instead of "1.x" and "2.x"). If anything here looks good, I can mod this branch to make additional updates. Otherwise, nevermind. Just spit-ball'in here. |
||
---|---|---|
.. | ||
1.x/UserSecrets | ||
2.x/UserSecrets |