khellang / Middleware

Various ASP.NET Core middleware
MIT License
811 stars 112 forks source link

How to disable developer exception page middleware? #189

Closed Jimmys20 closed 1 year ago

Jimmys20 commented 1 year ago

Hello, in ASP.NET Core 6 the developer exception page that used to be enabled using if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } is now enabled by default in Development environment. Any idea how to disable this behaviour and remove this middleware? How can I make the Problem Details middleware handle the error responses in development mode?

khellang commented 1 year ago

Hi @Jimmys20! 👋🏻

Unfortunately, there's no way to turn off the developer exception page middleware using the minimal hosting model. See this SO answer for more details.

Jimmys20 commented 1 year ago

Thanks for your reply, on Stackoverflow it is stated that "DeveloperExceptionPageMiddleware is executed after all custom registered middlewares". Does this mean that if I use app.UseProblemDetails(); with minimal hosting model the response will be actually handled by the ProblemDetailsMiddleware before DeveloperExceptionPageMiddleware is reached?

khellang commented 1 year ago

Yeah, I think that should be the case 👍🏻