Update Environment Tag Helper docs (#3794)

* Update Environment Tag Helper docs

* Update EnvironmentTagHelper.md
pull/3802/head
Hisham Bin Ateya 2017-07-21 23:27:23 +03:00 committed by Rick Anderson
parent 4ce4c6a3e5
commit 6cd0296ef2
1 changed files with 29 additions and 6 deletions

View File

@ -1,20 +1,19 @@
---
title: Environment Tag Helper | Microsoft Docs
---
title: Environment Tag Helper in ASP.NET Core
author: pkellner
description: ASP.Net Core Environment Tag Helper defined including all properties
keywords: ASP.NET Core,tag helper
ms.author: riande
manager: wpickett
ms.date: 02/14/2017
ms.date: 07/14/2017
ms.topic: article
ms.assetid: c045d485-d1dc-4cea-a675-46be83b7a035
ms.technology: aspnet
ms.prod: aspnet-core
uid: mvc/views/tag-helpers/builtin-th/EnvironmentTagHelper
---
# Environment Tag Helper
# Environment Tag Helper in ASP.NET Core
By [Peter Kellner](http://peterkellner.net)
By [Peter Kellner](http://peterkellner.net) and [Hisham Bin Ateya](https://twitter.com/hishambinateya)
The Environment Tag Helper conditionally renders its enclosed content based on the current hosting environment. Its single attribute `names` is a comma separated list of environment names, that if any match to the current environment, will trigger the enclosed content to be rendered.
@ -34,6 +33,30 @@ An example of a valid `environment` tag helper is:
</environment>
```
## include and exclude attributes
ASP.NET Core 2.x adds the `include` & `exclude` attributes. These attributes control rendering the enclosed content based on the included or excluded hosting environment names.
### include ASP.NET Core 2.0 and later
The `include` property has a similar behavior of the `names` attribute in ASP.NET Core 1.0.
```html
<environment include="Staging,Production">
<strong>HostingEnvironment.EnvironmentName is Staging or Production</strong>
</environment>
```
### exclude ASP.NET Core 2.0 and later
In constract the `exclude` property let the `EnvironmentTagHelper` to render the enclosed content for all hosting environment names except the one(s) that you specified.
```html
<environment exclude="Development">
<strong>HostingEnvironment.EnvironmentName is Staging or Production</strong>
</environment>
```
## Additional resources
* <xref:fundamentals/environments>