DEV Community

Senad Meškin
Senad Meškin

Posted on

ASP.NET Core - IIS Set environment in web.config

In order to set a Environment variable for the IIS hosted app via web.config we need to add <EnvironmentVariables> element inside the <aspNetCore> element.

<environmentVariables>
    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
Enter fullscreen mode Exit fullscreen mode

Example of your config should look like this:

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

</aspNetCore>
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
sunshine222025 profile image
SUNSHINE222025

​Great article on setting the ASPNETCORE_ENVIRONMENT variable in web.config for IIS-hosted ASP.NET Core applications! For developers working on macOS who need to run .NET Framework 4 applications without setting up a virtual machine, ServBay offers a seamless solution. It's been a game-changer for my development workflow.​