加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-core – ASP.NET Core忽略ASPNET_ENV和Hosting:Environ

发布时间:2020-12-16 06:34:03 所属栏目:asp.Net 来源:网络整理
导读:无论我何时何地设置ASPNET_ENV或Hosting:Environment,启动代码将始终进入 //This method is invoked when ASPNET_ENV is 'Production'//The allowed values are Development,Staging and Productionpublic void ConfigureProduction(IApplicationBuilder ap
无论我何时何地设置ASPNET_ENV或Hosting:Environment,启动代码将始终进入

//This method is invoked when ASPNET_ENV is 'Production'
//The allowed values are Development,Staging and Production
public void ConfigureProduction(IApplicationBuilder app,ILoggerFactory loggerFactory)
{
   loggerFactory.AddConsole(minLevel: LogLevel.Warning);

   Configure(app);
}

enter image description here

到目前为止我尝试过的

>在项目属性中设置主机:环境到开发
>在项目属性中将ASPNET_ENV设置为Development
>在launchSettings.json中设置托管:环境到开发
>在launchSettings.json中将ASPNET_ENV设置为Development
>通过Environment.SetEnvironmentVariable(“ASPNET_ENV”,“Development”)将ASPNET_ENV设置为开发代码;在调用ConfigurationBuilder.GetEnvironmentVariables()之前的Startup方法中

顺便说一下,这是版本1.0.0-rc2-20143.我在这里遗漏了什么,还是只是一个错误?

解决方法

作为名称更改的一部分,环境变量名称已更改为ASPNETCORE_ENVIRONMENT.

它于this issue年公布,并于this PR年更改.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读