Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

ASP.NET CORE 2: Using Correct appsettings.json Per Environment

$
0
0

Hi,

I've found that this issue is posted all over the internet but I have not found a working resolution.  The only approach that comes close to working is setting the environment variable in a web.config.  I'm open to correction, but to me, this is just a work-around.

My Setup:

  • Visual Studio 2017 ASP.NET CORE 2.03
  • Webapi app deployed as framework-dependent
  • Three appsettings.json files: one for dev, stage, prod
  • Three corresponding windows server running IIS 8 with ASPNETCORE module installed
  • Each server has it's own corresponding machine-level environment variable for "ASPNETCORE_ENVIRONMENT"

However, when I publish to any of the environments, "Development" is deemed to be the environment regardless of what the machine's environment variable is.  Like I mentioned, if I include the variable in the web.config, then that works but I don't understand why I have to do that.  I understand that ASPNETCORE module does not detect the web.config; whereas, IIS does.  

In my startup.cs I do have code such as the below but it makes no difference:

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else ...

Do I need different build/publish settings for each environment?  Is launchsettings involved?  

Thanks, cj


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>