What's the difference between
<environment include="...">...
and
<environment names="...">...
The official documentation doesn't help distinguish them at all (to me):
Environment Tag Helper in ASP.NET Core
names
... If any of the provided environment names match the current environment, the enclosed content is rendered ... Environment values are compared to the current value returned by IWebHostEnvironment.EnvironmentName
The content is rendered if the hosting environment is Staging or Production
<environment names="Staging,Production"> <strong>IWebHostEnvironment.EnvironmentName is Staging or Production</strong> </environment>
include
The include property exhibits similar behavior to the names attribute. An environment listed in the include attribute value must match the app's hosting environment (IWebHostEnvironment.EnvironmentName) to render the content of the tag.
<environment include="Staging,Production"> <strong>IWebHostEnvironment.EnvironmentName is Staging or Production</strong> </environment>
Even their code snippets use the identical self-description "IWebHostEnvironment.EnvironmentName is Staging or Production".
What's the difference between the two?
It seems that "names" is the older way, and "include/exclude" is the newer way.
A new
excludeattribute on theEnvironmentTagHelperlets you easily tell the EnvironmentTagHelper to render in all Environments EXCEPT the one(s) you specify. There’s also a newincludeattribute that behaves the same asnamesdid in ASP.NET Core 1.Exploring the Environment Tag Helper exclude and include attributes in ASP.NET Core 2
I guess that Microsoft kept the old names around for backwards compatibility. IDK why the documentation doesn't reflect that.
Based on my experience, the official documentation, and that article above, there isn't any functional difference between name and include. The name include just pairs better with exclude.