Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set hosting environment for a specific website?

My site is running under IIS among a dozen others. I want to set its hosting environment to Staging, but I can’t use ASPNETCORE_ENVIRONMENT environment variable to set it, because of the aforementioned other sites.

How can I set the hosting environment for a specific site.

P.S. Found the documentation that addresses this specific scenario. The short story is change web.config (yes, the legacy file).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

While it is not easy to find, but when Microsoft documented ASP.NET Core module they did provide sample code on how to set environment variables in web.config, so there is no need to follow the other answer to modify applicationHost.config.

<aspNetCore processPath="dotnet"
      arguments=".\MyApp.dll"
      stdoutLogEnabled="false"
      stdoutLogFile=".\logs\stdout"
      hostingModel="inprocess">
  <environmentVariables>
    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
    <environmentVariable name="CONFIG_DIR" value="f:\application_config" />
  </environmentVariables>
</aspNetCore>

It is the same web.config generated by dotnet publish, so I believe you feel natural that further changes go to the same place.

Another way you might want is to configure such environment variables on the application pool.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading