Environmental variables ignored for Layout in Area
<p>I have a problem in my ASP.NET Core MVC application.</p>

<p><strong>Can anyone advise why the tag helper for environment (names) isn't working for my (administration) layout page when located inside an Area?</strong></p>

<p>When referencing my scripts using the below code, it works when placed into the Standard _Layout.cshtml page but not a _Layout.cshtml contained within an area (used for an administration area).
I am ideally trying to modularise my code into Areas - the dashboard contains this _Layout.cshtml page for the administration area. </p>

<p>I discovered that all my css/js references were being included (unminified and minified and CDN).  So I put the below code into public layout and admin layout.</p>

<pre><code>&lt;environment names="Development"&gt;
  Development
&lt;/environment&gt;
&lt;environment names="Staging,Production"&gt;
  Staging production
&lt;/environment&gt;
</code></pre>

<p><strong>~/Views/Shared/_Layout.cshtml</strong> (public)</p>

<p>"Development" is displayed (good)</p>

<p><strong>~/Areas/Dashboard/Views/Shared/_Layout.cshtml</strong> (administration)</p>

<p>"Development Staging Production" is displayed (bad)</p>

<p><strong>My environmental variable is</strong>
ASPNETCORE_ENVIRONMENT (with a value of Development)</p>

<p><strong>My start up</strong></p>

<pre><code>public Startup(IHostingEnvironment env)
{
    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
        .AddEnvironmentVariables();

    if (env.IsDevelopment())
    {
        // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
        builder.AddUserSecrets();
    }

    Configuration = builder.Build();
}
</code></pre>

<p><strong>Configure method</strong>
...</p>

<pre><code>app.UseMvc(routes =&gt;
{
    routes.MapRoute(name: "areaRoute",
                    template: "{area:exists}/{controller=Home}/{action=Index}");

    routes.MapRoute(name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
});
</code></pre>

<p>Any help would be great - thank you.
Dan.</p>