asp.net-core - 在 "Development"环境中运行ASP.NET Core应用程序

标签 asp.net-core project.json .net-core-rc2

我正在使用 ASP.NET Core RC2,当我运行 dotnet run 时,我的应用程序始终在“生产”中运行。我无法将其更改为“开发”。

我有以下 launchSettings.json 文件:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:26088/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MVCCoreRc2App": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

当我设置 "ASPNETCORE_ENVIRONMENT": "Development" 时,我不确定为什么 dotnet 在“生产”中运行应用程序。

这在 ASP.NET Core RC1 中有效。我错过了什么?

最佳答案

从 Visual Studio 启动时使用 launchsettings.json,但从命令行 dotnet.exe 启动时不使用。

在调用 dotnet run 之前在控制台上设置环境变量。

设置 ASPNETCORE_ENVIRONMENT=开发

关于asp.net-core - 在 "Development"环境中运行ASP.NET Core应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37413374/

相关文章:

.net - 托管在 Windows 服务中的 Kestrel 的 Windows 身份验证

angular - Typescript + Angular 2 + ASP.Net Core 1.0 的 .html、.css 等文件应该位于哪里?

c# - 如何调试/修复 'An assembly with same simple name' 已导入

.net - 指定的依赖项是 X 但最终是 Y

.NET 核心 RC2 : use local fork of a package

c# - ASP.NET Core HTTPRequestMessage 返回奇怪的 JSON 消息

visual-studio-2015 - 指定帐户已存在 - .NET Core RC2 工具预览版 1

c# - 如何在存储库模式中执行异步等待?

asp.net - 新的 ASP.NET 5 (ASP.NET MVC 6) 项目类型能否以常规 .NET 为目标?

javascript - 如何在 Angular 员工 component.html 上返回 EmployeeCode?