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.
Developer Exception Page
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();
});
}
}
}
1 additional answer
Sort by: Most helpful
-
Zhi Lv - MSFT 32,646 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
toDevelopment
, check the following screenshot: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