Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app.UseDeveloperExceptionPage() doesn't seem to be working on ASP .NET Core on Ubuntu

Very simple ASP .NET core application so far. I've turned on the developer exception page as follows

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        loggerFactory.AddDebug();

        app.UseDeveloperExceptionPage();
        app.UseMvc();

    }

I've deployed it on windows as a portable app and i'm able to see the errors on the developer page (awesome page by the way) when a specific web API request fails with an exception.

I publish the same app to Ubuntu as a self-contained app and I don't get the developer error page to show up (though the seems to run fine - i've hard coded an error just to test the developer page itself).

like image 227
Mark Avatar asked Oct 25 '16 16:10

Mark


2 Answers

The Developer Exception Page is for use when the environment is Development.

See https://www.exceptionnotfound.net/working-with-environments-and-launch-settings-in-asp-net-core/

The act of publishing the app to Ubuntu is setting the environment to Production.

like image 128
John Davidson Avatar answered Oct 24 '22 13:10

John Davidson


By default on macOS and Linux ASP.NET Core's Hosting environment is Production.

On Ubuntu you can start the application and set the Hosting environment from command line using

> dotnet run --environment=Development

For macOS:

$ ASPNETCORE_ENVIRONMENT=Development dotnet run

If you are using Visual Studio Code, in launch.json there's the following setting for each configuration:

"env": { "ASPNETCORE_ENVIRONMENT": "Development" }

like image 40
Shayne Boyer Avatar answered Oct 24 '22 13:10

Shayne Boyer