Merge pull request #33732 from dotnet/Rick-Anderson-patch-7

Update configuration.md ropc
pull/33745/head
Rick Anderson 2024-09-27 14:25:34 -10:00 committed by GitHub
commit 9b7c3bf617
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -5,11 +5,10 @@ description: Learn how to migrate configuration from an ASP.NET MVC project to a
ms.author: riande
ms.date: 10/14/2016
uid: migration/configuration
ms.sfi.ropc: t
---
# Migrate configuration to ASP.NET Core
By [Steve Smith](https://ardalis.com/) and [Scott Addie](https://scottaddie.com)
In the previous article, we began to [migrate an ASP.NET MVC project to ASP.NET Core MVC](xref:migration/mvc). In this article, we migrate configuration.
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/migration/configuration/samples) ([how to download](xref:index#how-to-download-a-sample))
@ -20,6 +19,8 @@ ASP.NET Core no longer uses the *Global.asax* and *web.config* files that previo
The *web.config* file has also been replaced in ASP.NET Core. Configuration itself can now be configured, as part of the application startup procedure described in `Startup.cs`. Configuration can still utilize XML files, but typically ASP.NET Core projects will place configuration values in a JSON-formatted file, such as `appsettings.json`. ASP.NET Core's configuration system can also easily access environment variables, which can provide a [more secure and robust location](xref:security/app-secrets) for environment-specific values. This is especially true for secrets like connection strings and API keys that shouldn't be checked into source control. See [Configuration](xref:fundamentals/configuration/index) to learn more about configuration in ASP.NET Core.
[!INCLUDE [managed-identities](~/includes/managed-identities-test-non-production.md)]
For this article, we are starting with the partially migrated ASP.NET Core project from [the previous article](xref:migration/mvc). To setup configuration, add the following constructor and property to the `Startup.cs` file located in the root of the project:
[!code-csharp[](configuration/samples/WebApp1/src/WebApp1/Startup.cs?range=11-16)]