We'll dive into using TagHelpers by creating a project that behaves differently in each Environment: Development, Staging, and Production:
- First, let's use the Environment TagHelper:
<environment names="Development"> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" /> </environment> <environment names="Staging,Production"> <link rel="stylesheet" href=https://ajax.aspnetcdn.com/ajax/ bootstrap/3.3.6/css/bootstrap.min.css /> </environment>
The Environment TagHelper is mapped with an environment variable defined in the application's properties, ASPNETCORE_ENVIRONMENT. This variable is used in the application configuration in Startup.cs as an IHostingEnvironment type. The Environment TagHelper often includes ...