Developer Exception Page

KUNAL GUPTA 96 Reputation points
2021-08-20T14:53:04.53+00:00

I am new to ASP.NET Core and don't know much. I am using app.UseDeveloperExceptionPage() but still not able to see developer exception page. I am using windows OS. I have upload the project to Github. Here is the URL - https://github.com/gupta6/ConsoleToApI1 .

Below is my code.

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;

namespace ConsoleToApI1
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseRouting();

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }
}

}

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,232 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,363 questions
{count} votes

Accepted answer
  1. KUNAL GUPTA 96 Reputation points
    2021-08-21T09:49:31.88+00:00

    Hello, thanks to all for taking time to answer the question. But I have found the solution. There is a problem in the order of the execution in the startup file. I have first use routing and then check for development mode and this is wrong. The correct order for this is to first check the development mode and then use routing.125213-capture.png

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,036 Reputation points Microsoft Vendor
    2021-08-21T05:30:24.41+00:00

    Hi @KUNAL GUPTA ,

         if (env.IsDevelopment())  
         {  
             app.UseDeveloperExceptionPage();  
         }  
    

    From the above code, we can know that the Developer Exception Page only when the app runs in the Development environment. So, please check the application environment setting, make sure it is in the Development environment.

    I assume you are launching the application using IIS express, if that is the case, please open application's launchSettings.json file, and make sure you are setting the ASPNETCORE_ENVIRONMENT to Development, check the following screenshot:

    125185-image.png

    More detail information about setting environment, see Use multiple environments in ASP.NET Core.

    Besides, you can also set a break point at the app.UseDeveloperExceptionPage(); line, then in the debug mode, checks whether this method is executed or not. If this method is executed, the issue might relate your code, please check your code where throws the exception and is there have any exception handling page.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion