I have two web sites on my staging server, and both are ASP.NET Core sites that run in IIS. I have set the environment variable ASPNETCORE_ENVIRONMENT to
If you are debugging your code in Visual Studio, bear in mind that Visual Studio caches the environment variables that were present when Visual Studio was started - not when you hit "debug"!
So you may have to restart Visual Studio for any changes to the environment to be visible.