简体   繁体   中英

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 :

"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 . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM