[英]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.