.net core 默認會有 appsettings.Development.json 文件,這是根據ASPNETCORE_ENVIRONMENT來讀取的。
新建架構appsettings.Production.json用於生成環境
開發調試時通過此處進行配置。
正式環境發布
IIS版本 - - - 通過生成的 web.config 進行配置 ASPNETCORE_ENVIRONMENT 環境變量
<?xml version="1.0" encoding="utf-8"?> <configuration> <location path="." inheritInChildApplications="false"> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\TTTTTTTTT.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess"> <environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" /><!--Development--> </environmentVariables> </aspNetCore> </system.webServer> </location> <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Credentials" value="true" /> </customHeaders> </httpProtocol> </system.webServer> </configuration>
后續更新。。。。