Search code examples
c#jsonwindowsasp.net-coredevelopment-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:

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


Solution

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