SajjadZare
SajjadZare

Reputation: 2378

Environment in Web API and IIS

I have a web API in dot net core and there are three environments, Development, Staging and Production and I deploy it in Windows server with IIS I set environment variable for the website from configuration editor in the IIS, my problem is that when I don't set this item the API use my production environment, how can I fix this that if the environment doesn't set or can't find it the website doesn't use any environment?

Upvotes: 0

Views: 1442

Answers (1)

Ruikai Feng
Ruikai Feng

Reputation: 11939

Open your web.config and add the codes:

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

Upvotes: 1

Related Questions