diff --git a/aspnetcore/fundamentals/configuration.md b/aspnetcore/fundamentals/configuration.md index 7b33e7ea38..6d795ebfea 100644 --- a/aspnetcore/fundamentals/configuration.md +++ b/aspnetcore/fundamentals/configuration.md @@ -1,22 +1,24 @@ --- title: Configuration in ASP.NET Core author: rick-anderson -description: Learn how to use the Configuration API to configure an ASP.NET Core app from multiple sources. -keywords: ASP.NET Core,configuration,JSON,config +description: Use the Configuration API to configure an ASP.NET Core app by multiple methods. +keywords: ASP.NET Core,configuration,JSON,config,ini,XML,provider ms.author: riande manager: wpickett -ms.date: 6/24/2017 +ms.date: 11/01/2017 ms.topic: article ms.assetid: b3a5984d-e172-42eb-8a48-547e4acb6806 ms.technology: aspnet ms.prod: asp.net-core uid: fundamentals/configuration --- -# Configuration in ASP.NET Core +# Configure an ASP.NET Core App [Rick Anderson](https://twitter.com/RickAndMSFT), [Mark Michaelis](http://intellitect.com/author/mark-michaelis/), [Steve Smith](https://ardalis.com/), [Daniel Roth](https://github.com/danroth27), and [Luke Latham](https://github.com/guardrex) -The Configuration API provides a way of configuring an app based on a list of name-value pairs. Configuration is read at runtime from multiple sources. The name-value pairs can be grouped into a multi-level hierarchy. There are configuration providers for: +The Configuration API provides a way to configure an ASP.NET Core web app based on a list of name-value pairs. Configuration is read at runtime from multiple sources. You can group these name-value pairs into a multi-level hierarchy. + +There are configuration providers for: * File formats (INI, JSON, and XML) * Command-line arguments @@ -78,7 +80,7 @@ Configuration considerations: -## Using Options and configuration objects +## Use Options and configuration objects The options pattern uses custom options classes to represent a group of related settings. We recommended that you create decoupled classes for each feature within your app. Decoupled classes follow: @@ -157,13 +159,13 @@ The following sample demonstrates how a new `IOptionsSnapshot` is created after The following image shows the server output: -![browser image showing "Last Updated: 11/22/2016 4:43 PM"](configuration/_static/first.png) +![browser shows image with text that says "Last Updated: 11/22/2016 4:43 PM"](configuration/_static/first.png) Refreshing the browser doesn't change the message value or time displayed (when *config.json* has not changed). Change and save the *config.json* and then refresh the browser: -![browser image showing "Last Updated to,e: 11/22/2016 4:53 PM"](configuration/_static/change.png) +![browser shows image with text that says "Last Updated to,e: 11/22/2016 4:53 PM"](configuration/_static/change.png) ## In-memory provider and binding to a POCO class @@ -193,7 +195,7 @@ The following sample demonstrates the [GetValue](https://docs.microsoft.com/a The ConfigurationBinder's `GetValue` method allows you to specify a default value (80 in the sample). `GetValue` is for simple scenarios and does not bind to entire sections. `GetValue` gets scalar values from `GetSection(key).Value` converted to a specific type. -## Binding to an object graph +## Bind to an object graph You can recursively bind to each object in a class. Consider the following `AppOptions` class: @@ -244,7 +246,7 @@ public void CanBindObjectTree() -## Basic sample of Entity Framework custom provider +## Create an Entity Framework custom provider In this section, a basic configuration provider that reads name-value pairs from a database using EF is created. @@ -294,7 +296,7 @@ The [CommandLine configuration provider](/aspnet/core/api/microsoft.extensions.c [View or download the CommandLine configuration sample](https://github.com/aspnet/docs/tree/master/aspnetcore/fundamentals/configuration/sample/CommandLine) -### Setting up the provider +### Setup and use the CommandLine configuration provider # [Basic Configuration](#tab/basicconfiguration) diff --git a/aspnetcore/mvc/views/tag-helpers/intro.md b/aspnetcore/mvc/views/tag-helpers/intro.md index b7ae10001b..7315dda70f 100644 --- a/aspnetcore/mvc/views/tag-helpers/intro.md +++ b/aspnetcore/mvc/views/tag-helpers/intro.md @@ -35,13 +35,13 @@ Tag Helpers enable server-side code to participate in creating and rendering HTM Most of the built-in Tag Helpers target existing HTML elements and provide server-side attributes for the element. For example, the `` element used in many of the views in the *Views/Account* folder contains the `asp-for` attribute, which extracts the name of the specified model property into the rendered HTML. The following Razor markup: -```html +```cshtml ``` Generates the following HTML: -```html +```cshtml ``` @@ -57,13 +57,13 @@ Tag Helpers scope is controlled by a combination of `@addTagHelper`, `@removeTag If you create a new ASP.NET Core web app named *AuthoringTagHelpers* (with no authentication), the following *Views/_ViewImports.cshtml* file will be added to your project: -[!code-html[Main](../../../mvc/views/tag-helpers/authoring/sample/AuthoringTagHelpers/src/AuthoringTagHelpers/Views/_ViewImportsCopy.cshtml?highlight=2&range=2-3)] +[!code-cshtml[Main](../../../mvc/views/tag-helpers/authoring/sample/AuthoringTagHelpers/src/AuthoringTagHelpers/Views/_ViewImportsCopy.cshtml?highlight=2&range=2-3)] The `@addTagHelper` directive makes Tag Helpers available to the view. In this case, the view file is *Views/_ViewImports.cshtml*, which by default is inherited by all view files in the *Views* folder and sub-directories; making Tag Helpers available. The code above uses the wildcard syntax ("\*") to specify that all Tag Helpers in the specified assembly (*Microsoft.AspNetCore.Mvc.TagHelpers*) will be available to every view file in the *Views* directory or sub-directory. The first parameter after `@addTagHelper` specifies the Tag Helpers to load (we are using "\*" for all Tag Helpers), and the second parameter "Microsoft.AspNetCore.Mvc.TagHelpers" specifies the assembly containing the Tag Helpers. *Microsoft.AspNetCore.Mvc.TagHelpers* is the assembly for the built-in ASP.NET Core Tag Helpers. To expose all of the Tag Helpers in this project (which creates an assembly named *AuthoringTagHelpers*), you would use the following: -[!code-html[Main](../../../mvc/views/tag-helpers/authoring/sample/AuthoringTagHelpers/src/AuthoringTagHelpers/Views/_ViewImportsCopy.cshtml?highlight=3)] +[!code-cshtml[Main](../../../mvc/views/tag-helpers/authoring/sample/AuthoringTagHelpers/src/AuthoringTagHelpers/Views/_ViewImportsCopy.cshtml?highlight=3)] If your project contains an `EmailTagHelper` with the default namespace (`AuthoringTagHelpers.TagHelpers.EmailTagHelper`), you can provide the fully qualified name (FQN) of the Tag Helper: @@ -75,7 +75,7 @@ If your project contains an `EmailTagHelper` with the default namespace (`Author To add a Tag Helper to a view using an FQN, you first add the FQN (`AuthoringTagHelpers.TagHelpers.EmailTagHelper`), and then the assembly name (*AuthoringTagHelpers*). Most developers prefer to use the "\*" wildcard syntax. The wildcard syntax allows you to insert the wildcard character "\*" as the suffix in an FQN. For example, any of the following directives will bring in the `EmailTagHelper`: -```csharp +```cshtml @addTagHelper AuthoringTagHelpers.TagHelpers.E*, AuthoringTagHelpers @addTagHelper AuthoringTagHelpers.TagHelpers.Email*, AuthoringTagHelpers ``` @@ -98,7 +98,7 @@ You can add a *_ViewImports.cshtml* to any view folder, and the view engine appl You can disable a Tag Helper at the element level with the Tag Helper opt-out character ("!"). For example, `Email` validation is disabled in the `` with the Tag Helper opt-out character: -```csharp +```cshtml ``` @@ -110,7 +110,7 @@ You must apply the Tag Helper opt-out character to the opening and closing tag. The `@tagHelperPrefix` directive allows you to specify a tag prefix string to enable Tag Helper support and to make Tag Helper usage explicit. For example, you could add the following markup to the *Views/_ViewImports.cshtml* file: -```html +```cshtml @tagHelperPrefix th: ``` In the code image below, the Tag Helper prefix is set to `th:`, so only those elements using the prefix `th:` support Tag Helpers (Tag Helper-enabled elements have a distinctive font). The `