When running an ASP. NET Core application, Webhostbuilder determines which environment is currently running, possibly development,staging or production, based on the environment variables. You can also set it to a random string.
This link will show you how to set environment variables in various environments of various platforms. But if you use IIS to proxy ASP. You need to set environment variables in Web. config
<Configuration> <system.webserver> <handlers> <Addname= "Aspnetcore"Path="*"verb="*"Modules= "Aspnetcoremodule"ResourceType= "Unspecified"/> </handlers> <AspnetcoreProcesspath= "%launcher_path%"arguments= "%launcher_args%"stdoutlogenabled= "true"Stdoutlogfile= ". \logs\stdout"Forwardwindowsauthtoken= "false"> <Environmentvariables> <environmentvariablename= "Aspnetcore_environment"value= "Development" /> </Environmentvariables> </Aspnetcore> </system.webserver></Configuration>
You need to add the following to the Web. config
< Environmentvariables > < name= "Aspnetcore_environment" value= "Development"/> </environmentvariables>
How ASP. NET Core sets environment variables in IIS