1

Do the aspnet core hosting environments only matter when running locally using IISExpress?

I have environment specific configuration code that switches on the environment variable. Indeed, this all works fine when I change IIS Express to match the defined environment when debugging locally.

However when I go to publish the application, what environment will it choose? How can I control this?

Thanks for helping clear up my confusion.

proggrock
  • 3,239
  • 6
  • 36
  • 51
  • When publishing, You can set `ASPNETCORE_ENVIRONMENT` variable using command line or web.config. Refer [this](https://stackoverflow.com/questions/41546943/how-to-set-aspnetcore-environment-to-be-considered-for-publishing-an-asp-net-cor). – Sanket Aug 17 '17 at 14:32
  • Thanks Sanket, that gets me most of the way there. So if I have the Staging and Production on the same server, I would have to remember to swap out this variable in the web.config prior to publishing, sound right? – proggrock Aug 17 '17 at 14:42
  • Yes, that's what I am doing in my project. I have DEV and TEST environment on same server. – Sanket Aug 17 '17 at 14:45
  • Sanket, bonus question? If I DON'T specify the ASPNETCORE_ENVIRONMENT in the web.config, what would it choose? – proggrock Aug 17 '17 at 15:03
  • By default it takes as Production – Sanket Aug 17 '17 at 15:16

0 Answers0