简体   繁体   English

创建新的ASPNETCORE_ENVIRONMENT进行开发

[英]Create new ASPNETCORE_ENVIRONMENT for Development

I need a second Development environment that I call DevelopmentExt so I created this section in my launchSettings.json : 我需要第二个Development环境,称为DevelopmentExt因此我在launchSettings.json创建了此部分:

"CoolApp.DevelopmentExt": {
  "commandName": "Project",
  "launchBrowser": false,
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "DevelopmentExt"
  },
  "applicationUrl": "http://localhost:5000/"
},

In order to use different settings for this configuration I use this extension: 为了对此配置使用不同的设置,我使用以下扩展名:

public static class HostingEnvironmentExtensions
{
    public static bool IsDevelopmentExt(this IHostingEnvironment hostingEnvironment)
    {
        return hostingEnvironment.IsEnvironment("DevelopmentExt");
    }
}

This, however, gives me only general error pages and the browser says: 但是,这只给了我一般错误页面,浏览器说:

Swapping to Development environment will display more detailed information about the error that occurred. 交换到开发环境将显示有关发生的错误的更多详细信息。

I guess this indicates that my DevelopmentExt is not a real Development . 我猜这表明我的DevelopmentExt不是真正的 Development Is there a way that I can setup it to be recognized as such? 有什么方法可以将其设置为被识别吗?

As discussed in the comments, you'll need to change the condition to include the developer exception page middleware to: 如评论中所述,您需要将条件更改为将开发人员异常页面中间件包括在内:

if (env.IsDevelopment() || env.IsDevelopmentExt())

With it included, you should see detailed exceptions. 包括它在内,您应该看到详细的例外。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当 "ASPNETCORE_ENVIRONMENT": "Development" 时,无法从根提供程序解析范围服务 - Cannot resolve scoped service from root provider when "ASPNETCORE_ENVIRONMENT": "Development" .core mvc发布的应用程序局部视图在ASPNETCORE_ENVIRONMENT“生产”中不起作用,但在“开发”中工作良好 - .Core mvc published app partial views doesnt work in ASPNETCORE_ENVIRONMENT “production” but working fine with “development” 如何为控制台应用程序设置 ASPNETCORE_ENVIRONMENT? - How to set ASPNETCORE_ENVIRONMENT for console application? 在T4模板中获取ASPNETCORE_ENVIRONMENT? - Get ASPNETCORE_ENVIRONMENT in T4 Template? 如何在运行时设置 ASPNETCORE_ENVIRONMENT 变量 - How to set ASPNETCORE_ENVIRONMENT variable at runtime 是否可以重命名 ASPNETCORE_ENVIRONMENT 变量? - Is it possible to rename ASPNETCORE_ENVIRONMENT variable? 在构建配置中设置aspnetcore_environment - Set aspnetcore_environment within build configuration ASP.NET Core 3.1 - ASPNETCORE_ENVIRONMENT 的“开发”值在启动期间触发其他服务的生命周期验证 - ASP.NET Core 3.1 - `Development` value for ASPNETCORE_ENVIRONMENT triggers additional services' lifetimes validation during the startup 如何在 AzureDevops 中为 Dockerfile 设置环境变量(ASPNETCORE_ENVIRONMENT)? - How to set environment variables (ASPNETCORE_ENVIRONMENT) in AzureDevops for Dockerfile? AZURE_FUNCTIONS_ENVIRONMENT 与 ASPNETCORE_ENVIRONMENT - AZURE_FUNCTIONS_ENVIRONMENT vs ASPNETCORE_ENVIRONMENT
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM