当运行一个 Asp.Net Core 应用的时候, WebHostBuilder 根据环境变量来判断当前运行的是哪个环境,可能是 Development,Staging或者Production.你也可以设置成随便的一个字符串.
这个链接将会告诉你 如何在各种平台各种环境中设置环境变量.但如果你使用 IIS来代理 Asp.Net Core.你需要在 web.config 中设置环境变量
<
configuration
>
<
system.webServer
>
<
handlers
>
<
add
name
="aspNetCore"
path
="*"
verb
="*"
modules
="AspNetCoreModule"
resourceType
="Unspecified"
/>
</
handlers
>
<
aspNetCore
processPath
="%LAUNCHER_PATH%"
arguments
="%LAUNCHER_ARGS%"
stdoutLogEnabled
="true"
stdoutLogFile
=".logsstdout"
forwardWindowsAuthToken
="false"
>
<
environmentVariables
>
<
environmentVariable
name
="ASPNETCORE_ENVIRONMENT"
value
="Development"
/>
</
environmentVariables
>
</
aspNetCore
>
</
system.webServer
>
</
configuration
>
你需要把以下内容添加到 web.config
<
environmentVariables
>
<
environmentVariable
name
="ASPNETCORE_ENVIRONMENT"
value
="Development"
/>
</
environmentVariables
>
原文:http://www.cnblogs.com/hulk-/p/5947467.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!