.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>
后续更新。。。。